Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 1 of 11

One list holds the whole week

Show on a big screen

6 min

Text size

The rain gauge was read every morning this week. Each reading is that day's rain in millimetres. Seven numbers fit in one list, a row of boxes.

Loading lab…

Seven readings, in one list. Positions run 0 to 6.
Step 1 of 3
  1. Seven readings, in one list. Positions run 0 to 6.
  2. .length counts every box: 7.
  3. An empty list still has a length. It is 0.

The rule

A list holds many values, in order, under one name. Ask .length for the count — 0 for an empty list.

const rain = [6, 46, 2, 8, 0, 4, 4];

The word const gives the list the name rain. The first reading is at position 0, so rain[0] is 6.

That is one name for seven numbers.

One list, three questions
AskYou get
rain.length7
[].length0
rain[0]6

Remove a reading, and .length changes too. You do not count by hand.

Watch out!

.length is a count, not a position. The count is 7. The last position is 6.

Try the lab to finish this lesson.