1
var tupleSameProduct = function (nums) {3
let products = {}; // we'll keep track of how many times we've seen a given product before4
for (let a = 0; a < nums.length; a++) {5
for (let b = a + 1; b < nums.length; b++) {6
let product = nums[a] * nums[b];7
if (products[product]) {8
// we've seen at least one other pair of numbers with the same product already9
tupleCount += 8 * products[product]; // multiply by 8 because for any 4 numbers there are 8 permutations10
products[product] += 1; // increment the count, if we see this product again there are even more possible tuple combinations12
products[product] = 1; // mark as seen once