2

I have a 2 dimensional array:

const keys = [
    ['a'],
    ['one', 'two', 'three'],
    ['X', 'Y']
]

And I want to convert it to this format:

const output = [
    ['a', 'one', 'X'],
    ['a', 'one', 'Y'],        
    ['a', 'two', 'X'],
    ['a', 'two', 'Y'],         
    ['a', 'three', 'X'],
    ['a', 'three', 'Y']
]

The order of the output array is of importance. I have tried several approaches (recursive functions, a function that determines the fill length of the output and then fills in each position, etc.) but none of them seem to work...

Any help (code or concepts) would be much appreciated as this seemingly simple problem is giving me an headache.

JasperZelf
  • 2,731
  • 1
  • 22
  • 34

0 Answers0