Challenge 153 - Access Multi-Dimensional Arrays With Indexes

My problem here is not with the instructions of the challenge. I am pretty that have those down. My question is about the array that they give you to start. Code from the challenge is listed below.

`// 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];

I am new to this, but isn’t this missing a ] in there? Or am I missing something?`

Once I broke that line of code down onto separate lines it makes sense now… Also made solving the challenge more understandable too.

1 Like

If you mean myArray, no it’s got the correct amount of braces.
It can get confusing looking at arrays like this one though.
to demonstrate, we can remove all the proper arrays with open and closing brackets.
if you take away the first 3 arrays in myarray, you’re left with the confusing part,

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

// first lets remove the matching pair of braces that enclose myArray, leaving just the values inside.

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

//[1,2,3], [4,5,6], [7,8,9] all open and close simply enough, so take those away,

// whats  left is an array containing 1 array,  and 2 numbers.

[         [10,11,12], 13, 14         ] // white space is for easy visualization of outer arrays brackets (dont actually code arrays with it)


Seems, you got it while I was making this visualization. I probably would have confused you more anyway :stuck_out_tongue:

1 Like

Its essentially the steps I took to broke it down, now looking at it I can easily spot it. I was also expecting there to that closing brace due to the optics of it written as one. Once the outer braces of myArray are gone its time for the facepalm :smiley: