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 9 of 11

The big picture

Show on a big screen

3 min

Text size

One list, one loop. Every number here was worked out from them.

Data Handling I — eight ideas, in order
IdeaRememberExample
A row of values.length counts a list. 0 for an empty one.7 readings, 7
Reaching one of themPositions start at 0. Last is .length - 1.week[4] is Friday
Building it up.push() adds one value to the end.meals grows to 6
Adding them all upA total box outside the loop.0 → 28 → 59 → … → 166
The mean in codeTotal ÷ count, as a function.70 ÷ 7 = 10
Biggest and smallestWalk once, keep the best so far.78 is the heaviest
Counting into groupsA tally list, one slot per group.5, 3, 0, 4, 3, 3
Drawing it from the listBars are the printed counts.4 cells for tomato

Two numbers came up again and again. One is the count: .length, the loop's turns, the mean's divisor. The divisor is the number you divide by. The other is the position. The first position is 0 and the last is .length - 1.

Now the program does by machine what you once did on paper.