JavaScript solution, faster than 97.07% of JavaScript online submissions
\nvar countPairs = function(nums, k) {\n  let counter = 0\n\n  for (let i = 0; i < nums.length; i++) {\n    for (let j = i + 1; j < nums.length; j++) {\n      n
```\nvar countPairs = function(nums, k) {\n  let counter = 0\n\n  for (let i = 0; i < nums.length; i++) {\n    for (let j = i + 1; j < nums.length; j++) {\n      nums[i] == nums[j] && ((i * j) % k) === 0 ? counter++ : null\n    }\n  }\n  \n  return counter\n  \n};\n```
['JavaScript']