Using the loop counter inside a for loop
Inside a for loop, the counter i changes on every repeat, so using it in the loop body gives a different value each time, like 1, 2, 3. It only exists inside the loop.
Understanding Using the loop counter inside a for loop in ACARA Digital Technologies Years 7–8
What it does: With let i = 0 the loop prints 0, 1, 2, so the first value of i is 0 rather than 1. Because i is declared with let in the for loop, it only exists inside the loop. The console.log(i) after the loop cannot find it. The counter i goes up by 1 on every repeat, so console.log(i) prints a different value each time: 1, then 2, then 3. On the 3rd repeat i is 3, so i * 7 is 3 * 7 = 21. Starting at 0 would print 0 first, giving 0 to 5. Start at 1 to print 1 to 5.
Common mistakes: The variable is called doubled, not double. Using a name that was never created causes a ReferenceError. It should be console.log(doubled);. This prints 7 on every repeat because it uses the number 7 instead of the answer variable, which changes with i. It should end with + answer);.
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 583–598) and word search (Modules 583–613).
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
console.log(i)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →