Skip to content

Instantly share code, notes, and snippets.

@duggiemitchell
Created January 17, 2016 02:18
Show Gist options
  • Select an option

  • Save duggiemitchell/51973c0b627132311503 to your computer and use it in GitHub Desktop.

Select an option

Save duggiemitchell/51973c0b627132311503 to your computer and use it in GitHub Desktop.
Two-Dimensional Arrays
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 "Baby".
var movie1 = [16, "Candles"];
var movie2 = [3, "Men", "and", "a", "Baby"];
var eightiesMovies = [movie1, movie2];
> var infant = eightiesMovies[4];
____
Now alert a string with the full title of the first movie in the eightiesMovies array, but only using the eightiesMovies variable to access the correct values. Use the concatenation operator to unite the words into one string, and remember to be attentive to necessary whitespace!
var movie1 = [16, "Candles"];
var movie2 = [3, "Men", "and", "a", "Baby"];
var eightiesMovies = [movie1, movie2];
alert(eightiesMovies[0][0]+ " " +eightiesMovies[0][1]); //OR
alert(eightiesMovies.join(""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment