Accessing Multidimensional arrays with nested indexes?

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

// Only change code below this line.
var myData = myArray[0][0];

anyone here can help out on this? I’ve tried but i can seem to use bracket notation to read values from myArray…

1 Like

To access values you need to understand the indexing, in your case it’s like that:
…[0]…[1]…[2]…[3]…
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
…[0]…[1]…[2]

So to access say 11 you have to:

var myData = myArray[3][0][1];

W

2 Likes

thanks very much… i understand now…

var myData = myArray[2][1];

a tip i wrote down was to remember “Zero-Indexing” so therefore the first bracket would be 0, the next bracket would be 1, next bracket would be 2, etc etc…

This image is so helpful. Thank you

what does the number below indicate