- What did you use for your nine conditions?
- Why?
Arrays are extremely useful for storing ordered lists of data. Think of them as the lists that most data are organized into in scripting languages.
On your day4 branch, declare a var and define it with an array containing:
Arrays are indexed. This means you can access the members via reference by their numbered index.
var favArtists = ['ke$ha', 'Drake', 'Bush', 'Beck'];
alert(favArtists[0]);
Great! We can manipulate data in an array. But what about more complicated arrays?
var favoriteMovie = ['Star Wars VI', '1983'];
var secondFavorite = ['Return of the King', '2003'];
var thirdFavorite = ['Equilibrium', '2002'];
var myFavoriteMovies = [];
myFavoriteMovies.push(favoriteMovie, secondFavorite, thirdFavorite);
//Result:
[['Star Wars VI', '1983'], ['Return of the King', '2003'], ['Equilibrium', '2002']];
var movieYears = [];
movieYears.push(myFavoriteMovies[0][1], myFavoriteMovies[1][1],myFavoriteMovies[2][1]);
alert(movieYears);
In your scripts.js file, create 5 arrays, each with one of your top 5 movies' title and the main character's name
There is much more you can do with arrays. Read more about array methods here.
Get loopy! So we know how to store and manipulate data. Great! But how do we perform tasks on these data sets?
Why loops, of course!
Beware the infinite loops!
Now, using your favoriteMovies array:
There is much more you can do with arrays. Read more about array methods here.
On a takehome-day4 branch of your JS repository, write a program that: