JavaScript Solution
\nvar numTriplets = function(nums1, nums2) {\n    const squaredFreq1 = countSquareFreq(nums1);\n    const squaredFreq2 = countSquareFreq(nums2);\n    \n    retu
```\nvar numTriplets = function(nums1, nums2) {\n    const squaredFreq1 = countSquareFreq(nums1);\n    const squaredFreq2 = countSquareFreq(nums2);\n    \n    return countProdFreq(nums1, squaredFreq2) + countProdFreq(nums2, squaredFreq1);\n\t\n    \n    function countSquareFreq(nums) {\n        const freq = new Map();\n        \n        for (const num of nums) {\n            const squared = num * num;\n        \n            if (!freq.has(squared)) freq.set(squared, 0);\n            freq.set(squared, freq.get(squared) + 1);\n         }\n       \n        return freq;\n    }\n    \n    function countProdFreq(nums, freqMap) {\n        let count = 0;\n        \n        for (let i = 0;  i < nums.length - 1; i++) {\n            for (let j = i + 1; j < nums.length; j++) {\n                const prod = nums[i] * nums[j];\n            \n                if (freqMap.has(prod)) count += freqMap.get(prod);\n            }\n        }\n        \n        return count;\n    }\n};\n```
['Hash Table', 'JavaScript']