Skip to content
Exit presentation

Data Handling I: Organizing & Visualizing Data

One list holds the whole week

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.

Jump to lesson

This track

  1. 0 Start here
  2. 1 One list holds the whole week
  3. 2 Every item has a position
  4. 3 A list the program builds itself
  5. 4 One box outside the loop
  6. 5 Total divided by count
  7. 6 The biggest, without sorting
  8. 7 One count per group
  9. 8 The chart the program drew
  10. 9 The big picture
  11. 10 Track quiz

Other tracks