Lesson 8 of 10

Lists of things

An array is a list. Many things, in order, with one name.

Scene 1 of 5

A list keeps many things in order. One name, many things.

A list called fruits: apple, pear, plum.
Scene 1 of 5

Tip

Spots in a list start at 0, not 1.

Library

All about lists

What is an array?

An array is a list. It keeps many things in order under one name.

Square brackets

A list lives inside [ and ]. Commas go between the things.

Every spot has a number

The first spot is 0. The next is 1, then 2. fruits[0] means the first fruit.

Adding to a list

push adds a new thing at the end. The list gets longer.

How long is it?

fruits.length tells you how many things are in the list.

A list
["apple", "pear"]
A spot
fruits[0]
Add one
push

Words to know

  • array = a list
  • index = the spot number
  • push = add at the end