Access Multi-Dimensional Arrays With Indexes Problem

Tell us what’s happening:
So, as I’ve come across this, I really couldn’t understand what it was asking for, so, I tried YouTube for solutions. I did get it right, but, have no clue how the [2, 1] are the answer.

Your code so far

// 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[2][1];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

Think of it this way.

myArray is an array, and we can access its elements by index.

var simpleArr = ['a', 'b', 'c'];
// simpleArr[2] is 'b'
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// myArray[2] is [4, 5, 6]

Now we can see that myArray[2] is an array. That means we can access its elements by index.

var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// myArray[2] is [4,5,6]
var simpleArr = [4,5,6];
// we can easily see that simpleArr[1] is 4, so...
var myData = myArray[2][1]; // this must be 4

Hey Ariel,

Thanks for helping with me for the solution. Just to point out, a little correction. the “simpleArr[2]” is actually ‘c’ because JavaScript uses zero - indexing method.

Have a great day!

Ha! That’s what I get for multitasking.