Tracing a loop by hand
A table with one row per loop repeat, showing the counter, other variables and any output, filled in by hand until the condition is false.
Understanding Tracing a loop by hand in ACARA Digital Technologies Years 7–8
What it does: The trace table shows i as 2, 4, 6. The prediction is written first, then compared with the real console output. A trace table has one row per repeat of the loop. This lets you see how each value changes along the way. i starts at 1 and the loop runs while i <= 3, so it repeats 3 times. When i becomes 4 the condition is false and the loop stops. Repeat 1: total = 0 + 1 = 1, then n becomes 2. Repeat 2: total = 1 + 2 = 3, then n becomes 3. The total adds up each time.
Common mistakes: The variable is misspelled as totl, so JavaScript throws a ReferenceError. It should be console.log(i, total); so the output matches the trace table columns i and total. count + 1; works out a value but never stores it, so count stays 0 in every row of the trace table and the loop never ends. It should be count++; (or count += 1;).
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 624–634) and word search (Modules 611–634).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
trace tableFill in the Blanks
Spot the Error
Student with a class code? Join your class →