October workshops are openBuild a Search AI Agent$99 early bird

Enroll now
Skip to content

PATHWAY PROJECT · STARTER PROJECT · 2 SMALL IDEAS + A GUIDED LAB

Lunch-waste measurement helper

A total of 502 looks precise. What if one entry was kilograms, another was grams, and a third was counted twice?

You will learn to: Normalize fictional measurements, exclude invalid or duplicate records, and keep the observation period visible.

Preparing your lesson and this browser’s progress…
Read the complete lessonAll the ideas in one place · works without the editor

Use these notes to review a concept or read at your own pace. The interactive workspace above adds predictions, editable code, and actual run results.

IDEA 1

A number needs a unit and a measurement context

A mass value without a unit is incomplete. One kilogram equals 1,000 grams, so 0.5 kilograms and 500 grams represent the same mass. Convert every valid row to a common unit before adding values.

A measurement also needs context: its record ID, time, and scale status. The classroom tool rejects negative or nonnumeric mass, missing or unsupported units, a failed scale status, and readings outside the declared period. It does not repair unknown values by guessing.

Normalize before adding

  1. Observe. A row records half a kilogram during the audit period.
  2. Validate. Check unit, value, time, and the fixture scale-status field.
  3. Convert. Express the accepted reading in grams.
  4. Sum. Only normalized valid rows enter the total.

Synthetic cafeteria readings, not measurements or findings about a real school.

Never add unlike units directly

// Wrong: 0.5 kg + 250 g is not 250.5 g.
const totalGrams = 0.5 * 1000 + 250; // 750

The conversion changes representation, not the underlying mass. The final field totalGrams states the output unit explicitly.

Think it through: A row says mass: 500 but has no unit. What is justified?

IDEA 2

Duplicates and exclusions belong in the report

A repeated record ID may be the same measurement delivered twice. This exercise keeps the first occurrence of each ID and marks later occurrences duplicate-id before validation. That rule is explicit: it does not guess that the later row is a correction.

The result contains totalGrams, includedCount, excluded IDs and reasons, and the exact audit period. A zero total can mean no valid readings, so the count matters. This small sample cannot establish school-wide waste trends or environmental impact.

Make the denominator of your total visible

  1. Remember IDs. Track IDs only within this run to avoid double counting.
  2. Exclude. A second bin-a row receives a specific reason.
  3. Report. Keep the count and period next to the mass total.

Minutes 720–750 mean 12:00–12:30 in the fictional day; the end is excluded.

Detect a repeated ID before adding mass

if (seen.has(row.id)) {
  excluded.push({ id: row.id, reason: "duplicate-id" });
  continue;
}
seen.add(row.id);

continue skips the remaining processing of this duplicate. The first occurrence is remembered even if it later fails validation, so the rule consistently favors the first observed record.

Think it through: The result is 0 grams with includedCount: 0. What can you conclude?

Put it into practice

Sum each valid ID once in grams and return exclusions with the exact period.

  1. Read the units and scaleStatus fields before predicting the total.
  2. Run the starter and inspect the duplicate ID being counted twice.
  3. Insert the seen-ID guard at the start of the row loop.
  4. Run mixed-unit, invalid-reading, and period-boundary cases.
  5. Change an invalid row to valid and predict both the mass and included count.

Your next experiment: Change unit to kg, then compare the total. Why must a unit correction be a deliberate data change?

A defensible total preserves units, unique records, exclusions, and the limits of the observation period.

Key terms

Normalization
Converting values to a common representation so they can be compared or combined correctly.
Duplicate
A repeated record identity; this exercise retains its first occurrence.

Sources and scope

Original Stemtiq teaching, reviewed 2026-09-14. The named researchers and organizations do not endorse this course. Classroom cases are authored exercises, not published findings.

MDN Web Docs: JavaScript Guide

Updated 7 November 2025

Functions, objects, conditions, loops, and asynchronous code provide the programming foundations for an agent controller.

Ordinary JavaScript rules do not imply that a language model is running. An execution environment may support only part of the language or its host APIs.

Anthropic: Writing effective tools for agents — with agents

11 September 2025

Design distinct tools with clear parameters, relevant returned information, and evaluations of how the agent actually uses them.

A description or schema does not guarantee the right action. A live tool can return different data for the same arguments as its environment changes.

Anthropic: Demystifying evals for AI agents

9 January 2026

Define tasks, trials, and graders; inspect both execution records and final outcomes; repeat trials when model behavior varies.

A score depends on its cases and grading rules. Repeating a deterministic classroom case does not measure the variability of a live model.

Your JavaScript really runs. The model decisions and school data are authored simulations, so you can learn without an API key. Every workspace also includes a separate real SDK example to explore next. Passing the lab’s cases is practice, not proof that an agent is ready for real-world use.