I have an argument in function which expect array of arrays like = [[a,b], [1,2], [*,#]]
. The number of arrays in array may varys. It can be one, two or many.
How to get all possible variations of arrays values, like:
a1*
a1#
a2*
a2#
b1*
b1#
...
I know how to do it if the number of arrays is known. But how to combine if the number of arrays is not known?
Update:
let first = [`a`, `b`];
let second = [`1`, `2`];
let third = [`*`, `#`];
for (let i = 0; i < first.length; i++) {
for (let j = 0; j < second.length; j++) {
for (let k = 0; k < third.length; k++) {
console.log(first[i] + '/' + second[j] + '/' + third[k]);
}
}
}