Skip to content
Exit presentation

Data Handling I: Organizing & Visualizing Data

One count per group

One morning, eighteen slips are in the basket. A slip is a small paper note for one child's plate. It names the child's class. The cook wants a count per class.

Loading lab…

Six groups: 6A, 6B, 7A, 7B, 8A, 8B. Every count starts at 0.
Step 1 of 3
  1. Six groups: 6A, 6B, 7A, 7B, 8A, 8B. Every count starts at 0.
  2. The slips are counted. 7A gets a row too — count 0.
  3. The six counts add back to 18 slips.

The rule

A tally is a list of counts, one per group. It is built one add at a time. A group with nothing in it still gets a row. That row says 0.

const groups = ["6A", "6B", "7A", "7B", "8A", "8B"];

const counts = [0, 0, 0, 0, 0, 0];

groups holds the six class names. counts holds one count for each class, all starting at 0.

One walk over the slips adds one to the right count. The counts end as 5, 3, 0, 4, 3, 3. In order, 6A has 5, 6B has 3 and 7A has 0. Then 7B has 4, 8A has 3 and 8B has 3. Check: 5 + 3 + 0 + 4 + 3 + 3 = 18.

7A was on a trip, so no slip says 7A. The program still lists 7A. So 7A keeps a row, and the row says 0.

The same slips group another way. The first character is the year: 6, 7 or 8. The year counts are 8, 4 and 6. Check: 5 + 3 = 8, 0 + 4 = 4, and 3 + 3 = 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