Tell us what’s happening:
Describe your issue in detail here.
I cant get my head around this…
I watched a you tube vid and it said to access element " blue" in this , for example
let colors = [
[‘yellow’, ‘pink’ [ 'blue]]
]
would be colors[0][2][0]
is this right?
I’ve also looked at the answer for this challange.
and when i do this,
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”]], //<<<< i added this ‘deep’
[‘mutate’, 1327.98, ‘splice’, ‘slice’, ‘push’],
[‘iterate’, 1.3849, 7, ‘8.4876’, ‘arbitrary’, ‘depth’]
// Only change code above this line
];
console.log(myNestedArray[2][6][0])
TypeError: Cannot read property ‘0’ of undefined << why is this coming up when i have copied something from this answers?
Are all the lines in the example all level 2 as no nesting has been done yet?
And does each time you do a e.g my NestedArray[0][1][2] << this would refer to 3 depths of the array and the third depth would be an array, inside an array inside an array?
In the example it gives:
Ive tried to label the levels, is this correct.
to access the second deepest i thought i would do
console.log(nestedArray[3][2][0])
but i just get error: TypeError: Cannot read property ‘2’ of undefined
let nestedArray = [ // level 0
['deep'], // level 1
[ // level 1
['deeper'], ['deeper'] // level 2
],
[ // level 1
[ // level 2
['deepest'], ['deepest'] level 3
], level 2
[ // level 3
[ // level 4
['deepest-est?'] level 5
] // level 4
] // level 3
] // level 2
]; // level 1
console.log(nestedArray[2][1][0][0][0]); <<< = deepest-est?
but when i console log it, console.log(nestedArray[2][1]), also equals deepest-est? so why do you need to put the 5 level of depth when the result is found at just 2??
Sorry, i hope this makes sense, i really cant get past this bit :(
**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'],
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
// Only change code above this line
];
console.log(myNestedArray[2][6][0])
Hope someone can help me get my head around this.
thanks
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Challenge: Create complex multi-dimensional arrays
Link to the challenge: