Confused about the answer

Tell us what’s happening:
on the accessing data with multi dimensional arrays lesson, the answer Is var myData = myArray[2][1]; im really confused about this because the example shows that the answer was arr[3][0][1] to find 11, so why is there only 2 brackets for our answer ? shouldn’t it be ```var myData=myArray[2][0][1];? are we not supposed to include the 0?

Your code so far

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

var myData = myArray[2][1];

Your browser information:

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

Challenge: Access Multi-Dimensional Arrays With Indexes

Link to the challenge:

Try to apply the programming rules you’ve learned so far and answer:

  • Which element does myArray[3][0][1] refer to?
  • Which element does myArray[2][1] refer to?
  • Which element does myArray[2][0][1] refer to?
1 Like

I get the first and third ones, but its the second one im confused about. according to the example, the middle number is supposed to represent all the numbers in the array. " arr[3][0] is [10, 11, 12]" thats why im confused when it only has 2.

I think the first number is to represent the entire array, the second is the same, while the third represents the specific number itself. so array [3][0[1] would go down to the third array, and the second number because java counts from 0. am I on the right track?

Unfortunately it doesn’t.

Not really. I recommend that you take another detailed look at this challenge: Learn Basic JavaScript: Access Array Data with Indexes |

1 Like

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