Arrays: Lists of Things

An array keeps a list in order: songs on a playlist, items in a cart. Learn to read items by their position, add and remove them, loop through them, and find the one you're looking for.

Updated

Arrays in JavaScript

  1. What Is an Array (Novice): An array keeps a whole list of values, such as the songs on a road-trip playlist, under one name, and you reach each one by its position, counting from 0.
  2. Adding and Removing Items (Apprentice): Grow and shrink an array as things change, adding and removing items at the end with push and pop, at the front with unshift and shift, and in the middle with splice.
  3. Looping Through an Array (Apprentice): Visit every item of an array with a for loop, a for...of loop or forEach, and use a loop to add up or count things, such as a playlist's total play time.
  4. Finding Things in an Array (Apprentice): Ask an array questions instead of writing a loop for each one, with includes and indexOf for an exact value, and find, findIndex, some and every for any test you write.

Exercise: Road-Trip Playlist

  1. Exercise: Road-Trip Playlist (Apprentice): Finish five functions that keep a road-trip playlist up to date, adding and removing songs, totaling the play time and checking for a song, and let the tests check each one.