var movie1 = [16, "Candles"];
var movie2 = [3, "Men", "and", "a", "Baby"];
var eightiesMovies = [movie1, movie2];
Two-dimensional arrays can actually be a really difficult concept at first. Be patient with yourself. We're basically starting out with two arrays, and they are stored as sub-arrays in
Check out the following setup. Enter a line of code that declares a variable called
infant and uses the array
eightiesMovies to access the word
The first part is fairly straightforward in that we want to create an
infant variable, but then it gets a little complicated when we want to access the correct value.
var infant = eightiesMovies<access_value_here>
Using the Chrome DevTools is usually a good way to get a grasp of working with array values. Here's what the
eightiesMovies array looks like:
What the challenge is asking for is to access the
"Baby" string from that second array.
First, we can access that second array with this and see the returned values:
> [3, "Men", "and", "a", "Baby"]
The to access the sub-arrays we can use a second set of brackets.
Knowing that array indexes are zero-based, we can use
4 to access the correct value:
If you get stuck anywhere in the course, feel free to check out the provided solutions that are already available for every challenge. And don't forget to review the video lecture for this section if you're having trouble!