Could somebody help me understand these Arrays?

Tell us what’s happening:

I peaked ahead at the Solution, but it does not make any sense to me.

From what I see, there are 5 arrays to begin with, nested within the “myNestedArray”

but when submitting code, im being told there is not 5 layers of depth… then what are these here? they certainly are Arrays, and they are within another Array, so how are they not 5 layers deep?

Honestly, I usually have to look at the solutions, simply because the Examples FCC gives makes it more difficult to understand the concept were trying to learn.

Your code so far


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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

Challenge: Create complex multi-dimensional arrays

Link to the challenge:

let myNestedArray = [
// change code below this line
[“unshift”, false, 1, 2, 3, “complex”, “nested”],
[“loop”, “shift”, 6, 7, 1000, “method”],
[“concat”, false, true, “spread”, “array”, [“deep”]],
[“mutate”, 1327.98, “splice”, “slice”, “push”, [[“deeper”]]],
[“iterate”, 1.3849, 7, “8.4876”, “arbitrary”, “depth”, [[[“deepest”]]]]
// change code above this line
];

Furthermore, this makes no sense to me either.
Why is deep nested in between 1 set of brackets, and why is deeper in 2 sets and deepest in 3.

This is very very confusing.

Look at the nestedArray in the challenge example. You can basically copy and paste that (just the array not the name) and then change the strings as required.

// Change the strings as required

let myNestedArray = [ // top, or first level - the outer most array
  ['deep'], // an array within an array, 2 levels of depth
  [
    ['deeper'], ['deeper'] // 2 arrays nested 3 levels deep
  ],
  [
    [
      ['deepest'], ['deepest'] // 2 arrays nested 4 levels deep
    ],
    [
      [
        ['deepest-est?'] // an array nested 5 levels deep
      ]
    ]
  ]
];

Copying and pasting doesn’t help me understand whats going on.

You can look at the structure and compare it to what you have. Do you not see the difference in the nesting of the arrays?

You can nest an array, inside an array. That array can also have an array inside it. And so on and so on. Think of boxes within boxes.