I am looking for a way to calculate cartesian product in EcmaScript 6
Example :
product([["I", "They"], ["watch", "drink"], ["the sea", "the juice"]])
Expected result :
[["I", "watch", "the sea"], ["I", "watch", "the juice"], ["I", "drink", "the sea"], ["I", "drink", "the juice"], ["They", "watch", "the sea"], ["They", "watch", "the juice"], ["They", "drink", "the sea"], ["They", "drink", "the juice"]]
Example :
product([[-1, -2], [10, 20]])
Expected result :
[[-1, 10], [-1, 20], [-2, 10], [-2, 20]]
for..ofloops ifarr2is not and element ofarr1?javascriptat Question, and none of nested loops appearing to depend on property or value from precedingfor..loop, not certain what expected result is?