6. Arrays of arrays. Any way to access the 2nd tier specific value?


#1

Is there any way to access a second or third degree specific array value?

This is the lesson I was working on when I though of this question.

var newArray = [
   ["Demonbaby", "Junior", "Slice"],
   [666, 69, 13],
   ["Candy", "Murder", "Torture"]];

console.log (newArray[0]);

I want to log "Demonbaby" to the console. Any way to access just that one value of the second tier array?


#2

I believe that you can use:

console.log[0,0];

#3

Nope, that calls the entirety of the array located at the final term of the address located:

console.log[2,3,4,1,2,1,2,2,0];

will only recall the FINAL term in the address. Not sure what the previous terms do, but I'm just looking for the first position in the first array.
Any other ideas?


#4

In a multi-dimension list, we have a list of lists. We can think of it as a grid-like array, but it is still linear.

var array = [];
array.push(['first row", 'second element']);
array.push(['second row', 'second element']);
array.push(['third row', 'second element']);

console.log(array[0][1]);    // second element

console.log(array[1][0]);    // second row

#5

AHHHHH!!! You again! Amazing! Thanks. That was going to bug me for days.


#6

Interesting. As with everything unknown, google it!


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.