# Basic JavaScript - Access Multi-Dimensional Arrays With Indexes

Tell us what’s happening:
So I understand this to en extent and I am able to pass.

My question revolves on the Nested Array, and how in the intro it says that the element = 11.

I am looking to see if someone can explain how this works
const element = arr[3][0][1]; would work out to be 11 in the …

const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
];

I understand that 11 is in the sub array and in the nested array,

It is also in the position 3 in reference to the array that it is in

Its in the 2nd spot (aka 1) but I am confused on where the [0] fits in this arr= [3][0][1];?
like how does arr=[3][0][1]; equal 11???

Hopefully this explains my question and logic.

``````const myArray = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14],
];

const myData = myArray[2][1];
console.log(myData)
``````

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

Challenge: Basic JavaScript - Access Multi-Dimensional Arrays With Indexes

I think you meant “how does `arr[3][0][1]` equal `11`”.

Each one of those brackets is an array index, so just replace them with their actual values, starting at the left. For example, `arr[3]` is `[[10, 11, 12], 13, 14]` because that’s what’s in the fourth element of `arr`. So now you can write the original as:

`[[10, 11, 12], 13, 14][0][1]`

So what is the first element of the array `[[10, 11, 12], 13, 14]`? It’s `[10, 11, 12]`, which is the value of `[[10, 11, 12], 13, 14][0]`. So you can rewrite `[[10, 11, 12], 13, 14][0][1]` as:

`[10, 11, 12][1]`

And then the the value of this is `11`.

1 Like

Is it because the 3rd array has a nest?

It’s the 3rd array [3]

then the nest is [0]

and it’s the 1 [1] value in the nest

which is
11?.?.?

Does that make sense?

I feel like what you said make sense, and I feel as though I’m getting it, just need clarification.

1 Like

yes correct.
The 3rd index is itself a nested array.
and the 0th index of that is an array
and the 1th index of that is 11

1 Like

Thank you @bbsmooth and @hbar1st !

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.