Access MultiDimensional Arrays With Indexes still not working out

Access MultiDimensional Arrays With Indexes still not working out
0

#1

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]];
var myArray = [4][0]; // equals [[1,2,3], [4,5,6],[7,8,9]];
var myArray = [4][1]; // equals [[10,11,12], 13, 14];
// Only change code below this line.
var myData = myArray[4][0][4][1]; // equals 8 

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:47.0) Gecko/20100101 Firefox/47.0.

Link to the challenge:


#2

myArray is only a two-dimensional array, but your code is trying to reference a third and fourth dimension. The challenge wants you to assign the value 8 to myData, so you need to understand how to access values from the two-dimensional array myArray.

The first dimension is defined by the outer [ ], so myArray’s first dimension has 4 elements as follows:

1st is [1,2,3]
2nd is [4,5,6]
3rd is [7,8,9]
4th is [[10,11,12], 13, 14]

To access a specific element of myArray, you would be simply write:

myArray[index] // where index represent the 0-based index of the element you want to access.

To access a second dimensional element of myArray, you would be referencing an element of an array contained inside of myArray. In the current example, there are 4 “sub arrays” in myArray. Let’s say I want to refer to the 1st element of the 2nd sub array of myArray, I would write:

myArray[1][0] // the 1 represents the 2nd element of myArray and the index represents the 1st element of the 2nd element (a sub array) of myArray.

#3

Thanks, but still did not work out.


#4

Can you post your code?


#5

Lol, No need, I debugged my code on my own, actually, I found it easier doing research than asking for explicit answers which limits my understanding of the code functionality.
Thanks