Array inside an array


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-9Sgpi/1/2?curriculum_id=506324b3a7dffd00020bf661#


Hi,

I'm trying to understand how to reference a value inside a 2D array.
My code is this:

var newArray = [[10, "city", true], [11, "continent", false], [12, "country", true]];
console.log(newArray[1,1]);


The output is:
[ 11, 'continent', false ]

If i have to print only the value "continent" from my array, how should i reference it?

should i use: newArray[1[1]] ? I tried this too, but the output says 'undefined'.


#2

newArray[1][1]

#3

Thanks Konaesan. This worked!


#4

@gigarockstar76103 You're welcome :+1:


#5

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