Access MultiDimensional Arrays With Indexes - JavaScript Challenge

Tell us what’s happening:

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[8][0];

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; CrOS x86_64 10032.86.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.140 Safari/537.36.

Link to the challenge:

Any tips on this one?

First, explain why you tried myArray[8][0]? What do you think the 8 and 0 represent?

If you had the following array:

var myArray = [10, 20, 30];

How would you assign the value 20 to another variable called valueTwenty?

var valueTwenty = ???;

Replace the ??? above with what you think would reference the actual value of 20 in myArray.

If you are struggling with answer my second question above, then I suggest you revisit the following challenge on accessing array data with indexes.

var myData = myArray[8][0] is just one of many guesses.

I forget what my original intuition for this problem was.

When you can answer my second question, I will give you another hint to help you solve the current challenge.

Also, I would guess 1 would align with 20.

I am going to assume you meant the following:

var valueTwenty = myArray[1]; // index 1 refers to 2nd element in myArray which is the value 20

Yes. But does that relate to this challenge?

Now using the current challenge code for myArray, what if I asked you to refer to the element inside myArray which represents [7, 8, 9]? Fill in the blank below:

var subArray789 = myArray[ ??? ];
1 Like

Figured it out. thanks

Thank You!
I couldn’t figure out what to call a nested array :smiley: