Can someone explain the concept of accessing multi-dimensional arrays with indexes?
const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
How is arr = [[10, 11, 12], 13, 14]?
How is arr= 11? Why is the  included in the index when it should just be ?
If I gave you the following array:
numberArray = [5, 6, 7, 8]
numberArray would equal
8 because that is the value of the fourth item in the array.
But instead of numbers, the
arr array contains arrays. But it’s still the same concept. So what array is in the fourth spot in
HI @Honeybee !
Dealing with nested arrays can be confusing at first.
It helps to remember that you can access elements from an array using bracket notation.
arr tells the computer to access the element at index 3.
Each element in our array is separated by commas and we start counting at index 0.
Here is our array.
This is is special because there is an array nested inside.
We first have to tell the computer to go to element at index 3, which is this syntax :
Now this array has three elements.
First try to identify what those three elements following the same steps we did earlier when we were trying to find
Then once you can identify those three elements, focus on the first one which is another array.
This array has three elements of its own.
Walk through those same steps as earlier, to identify those three elements.
By slowly walking through those steps it should help you understand how we got to this.
Well remember that
arr would be this.
arr tells the computer to go to index 1 of
The number 13 is the element at index 1 of
Hope that helps!
Thanks a lot, it’s clear for me now !!