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

Total divided by count

Show on a big screen

6 min

Text size

One number for the whole week. Share the week's total equally between the days. What each day holds is the mean.

Loading lab…

Seven bars for the week. Values shown above each one.
Step 1 of 4
  1. Seven bars for the week. Values shown above each one.
  2. All seven add up. Total = 70.
  3. Seven days in the list. Count = 7.
  4. Mean = 70 ÷ 7 = 10, ruled across the strip.

The rule

A function is a named set of lines. This function gives back one answer.

The mean is the total divided by the count. Written as a function, it works on any list you hand it. Longer or shorter, the lines do not change.

  • let total = 0; — the box, outside the loop.
  • total = total + day; — each reading added on.
  • return total / days.length; — divide, then give back the answer. The sign / means divide.

The count comes from .length. Nothing is counted by hand.

Monday to Saturday is six days, total 66. The mean is 66 ÷ 6 = 11. The whole week is seven days, total 70. Its mean is 70 ÷ 7 = 10.

If Tuesday were 45, not 46, the total is 70 − 1 = 69. 7 does not divide 69 evenly. The machine prints 9.857142857142858. It does not round the answer.

Try the lab to finish this lesson.