Skip to content
Exit presentation

Programming + AI Capstone

Collect the day

The mela's check-in list has two mornings. A kite is written on it when it arrives, as one row. The sheet wants only today's.

Seven rows on the list: two from yesterday, five from today.
Step 1 of 5
  1. Seven rows on the list: two from yesterday, five from today.
  2. Row Y1: day says yesterday. Skipped.
  3. Row Y2: day says yesterday. Skipped.
  4. Rows A1 to A5: day says today. Each one is kept, whole.
  5. Kept: 5. Yesterday's two rows stay on the list, untouched.

The rule

Collect walks the list and keeps today's rows. A row is kept whole or skipped whole. The day column says which one it is.

  • headers.indexOf("day") finds which position holds the day. Here, headers is the list of column names.
  • row[dayColumn] === "today" is the test each row must pass. Here, dayColumn is the position found above.
  • today.push(row) keeps the whole row — kite, span, tail and day, together. Here, today is the new list. The push call adds a row to its end.

A row that fails the test is not deleted. The list still holds it; only today's copy leaves it out. The loop reads every row once, in order. It does not skip any row.

Watch which rows are added to today and which are not.

Loading lab…

Predict which row the loop is reading. Predict how many kites it has kept. Then reveal it.

Jump to lesson

This track

  1. 0 Start here
  2. 1 The plan, in plain words
  3. 2 Collect the day
  4. 3 The distance between two
  5. 4 See the board
  6. 5 Write the classifier
  7. 6 When the nearest is wrong
  8. 7 Assemble and report
  9. 8 Who it gets wrong
  10. 9 The big picture
  11. 10 Track quiz

Other tracks