I have an array in this form ...
- arr[itemDescription]
- [0] someValue1
- [1] someotherValue1
- arr[itemDescription]
- [0] someValue2
- [1] someotherValue2
- arr[itemDescription]
- [0] someValue3
- [1] someotherValue3
- ....
Now i would like to generate all possible variations where i have an array with the first item combined with the other elements, the second element combined with the other elements and so on. Like:
- [someValue1][someValue2][someValue3]
- [someValue1][someotherValue2][someValue3]
- [someValue1][someotherValue2][someotherValue3]
- ....
to sum up, for the folowing input array:
[[11, 12], [21, 22], [31, 32]];
I need to obtain an output array like
[[11, 21, 31], [11, 21, 32], [11, 22, 31], [11, 22, 32], [12, 21, 31], [12, 21, 32], [12, 22, 31], [12, 22, 32]];
Can somebody help me how I would do that in javascript?
Thank you a lot!