# Basic Data Structures - Create complex multi-dimensional arrays

the outer-most array is level 1 (there is no level 0)
The first “deep” we see is at level 2.
therefore it is nested “two levels deep”.

a flat array is flat because all its elements are at the same (first) level

a 2-d array is an array of arrays so anything in the “second level” is within the nested array within the array.

once you understand this you can extrapolate the rest for 3-d arrays etc

so it is like the following

let nestedArray = [ //1
['deep'], //2
[ //3
['deeper'], ['deeper']
],
[ //4
[
['deepest'], ['deepest']
],
[
[ //5 ? but how, this is nested
['deepest-est?']
]
]
]
];

The reason I said level 0 is array start at index 0

let nestedArray = [ //1
['deep'], //2
[ //2
['deeper' //3], ['deeper' //3]
],
[ //2
[ //3
['deepest' //4], ['deepest' //4]
],
[ //3
[ //4
['deepest-est? //5]
]
]
]
];

The following is what I made but it is still not passing, am I doing it wrong?

let myNestedArray = [ //1
// Only change code below this line
['unshift', false, 1, 2, 3, 'complex', 'nested'],
['loop', 'shift', 6, 7, 1000, 'method'],
['mutate', 1327.98, 'splice', 'slice', 'push'],
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth'
['deep'//3
['deeper' //4
['deepest']//5
]//4 end
] //3rd end
]//1st end
// Only change code above this line
];

I think you forgot the comma after this word depth

following is my code yet, it doesn’t pass. Can someone hint to me if I am right about levels now? The link is here

hi , I can’t see your new code.
But I was able to fix your old code by adding the missing commas.
Let me know if you need more help fixing it. (there is more than one missing comma)

here is the code

let myNestedArray = [ //1
// Only change code below this line
['unshift', false, 1, 2, 3, 'complex', 'nested'],
['loop', 'shift', 6, 7, 1000, 'method'],
['mutate', 1327.98, 'splice', 'slice', 'push'],
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth',
['deep'//3
[ 'deeper' //4
['deepest']//5
]//4 end
] //3rd end
]//1st end
// Only change code above this line
];

Not sure where I need the comma

I re-formated your code so it is easier to see where the commas are missing

on the second line, you need 2 commas more
after the word deep and after the word deeper

1 Like