1

I have the following array:

[
    [1],
    [2, 22],
    [3, 33, 333],
    [4]
]

I want to turn it into the following array:

[
    [1, 2, 3, 4],
    [1, 2, 33, 4],
    [1, 2, 333, 4],
    [1, 22, 3, 4],
    [1, 22, 33, 4],
    [1, 22, 333, 4],
]

The order of the numbers in each sub-array matters, but the order of the sub-arrays within the big one doesn't. 1 must always come before 2, and so on. I'm using numbers to simplify but they will be strings, so I can't use math for this.


Edit: A simple version of the above would be the following:

// the following:
[
    [1],
    [2, 22],
]
// would be converted to:
[
    [1, 2],
    [1, 22]
]
yaserso
  • 2,638
  • 5
  • 41
  • 73
  • Fixed the main example. If it's not right then use the simpler example. – yaserso Apr 06 '21 at 23:47
  • 1
    Can you share what _you have tried_? – maxshuty Apr 06 '21 at 23:52
  • @maxshuty This is what I have been trying to do: https://jsfiddle.net/yaharga/uega8ns7/90/ It's messy since I'm still working on it but I tried to search to find something along the lines of lodash or searching for "multidimensional array combinations" and found nothing. – yaserso Apr 07 '21 at 00:06

0 Answers0