×

javascript · level 1 · unit 6 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

An keeps many values together in one box.

A shopping list does not need a new piece of paper for every thing you buy. One list holds them all, in order. A JavaScript array does the same, so one variable can hold lots of values.

Write an array with square brackets [ ] and put a comma between the values. Each value in the array is called an . .length counts the items, not the letters.

Showing an array with console.log shows the square brackets and commas too, with no spaces. Text items keep their double quote marks, like ["bread","milk"].

let shopping = ["bread", "milk", "eggs"];
console.log(shopping);
console.log(shopping.length);

Arrays can hold numbers too, like [3, 7, 10].