Basic JavaScript - Access Multi-Dimensional Arrays With Indexes

Tell us what’s happening:
Please I need help understanding how element value got to be 11 In the Multi-Dimensional Arrays With Indexes example below .

Example

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

const subarray = arr[3];
const nestedSubarray = arr[3][0];
const element = arr[3][0][1];

In this example, subarray has the value [[10, 11, 12], 13, 14], nestedSubarray has the value [10, 11, 12], and element has the value 11 .

  **Your code so far**
const myArray = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14],
];

const myData = myArray[0][0];
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15

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

Link to the challenge:

const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
];
indexes starts from 0 so at the 3rd index there would be an array [[10, 11, 12], 13, 14] and at 0th index it has another array [10, 11, 12] and at its 1st index there is 11.

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

arr_3 = arr[3] // [[10, 11, 12], 13, 14]

arr_3_0 = arr_3[0] // [10, 11, 12]

arr_3_0_1 = arr_3_0[1] // 11
// same as
arr[3][0][1] // 11
1 Like

Thanks. Figured i was missing the point.