← ACARA Digital Technologies Years 7–8

Counting down with a for loop

A for loop that counts down: start i high, keep going while i >= 1, and subtract 1 each time with i--. Use i -= 2 to count down in steps of 2.

Understanding Counting down with a for loop in ACARA Digital Technologies Years 7–8

What it does: The condition i >= 1 stays true until i drops to 0, so the loop prints 10 down to 1. i-- takes 1 off i after each repeat. This moves the counter down towards the end of the loop. i-- subtracts 1 each time, so i gets smaller. i++ would add 1 and the loop would never stop. i starts at 3 and goes down by 1 each time, so the console shows 3, then 2, then 1. The condition i <= 1 is false when i starts at 10, so the loop body is skipped. A countdown needs i >= 1.

Common mistakes: i++ adds 1 each time, so i goes up (11, 12, ...) and i >= 1 stays true forever. A countdown must use i-- to subtract 1 each time. A countdown must start high. Starting at 1 makes i >= 10 false straight away, so the loop never runs. It should be let i=10 and i>=1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 599–610) 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.

Learning
Duo
Which for loop counts down from 10 to 1?
for (let i = 10; i >= 1; i--)for (let i = 10; i >= 1; i++)
Matches
for (let i = 10; i >= 1; i++)
↓
The update i++ adds 1, so the counter goes up away from 1 and the loop never ends. It should be i--.
Applying
Meanings
Term
for (let i = 10; i >= 1; i--)
Meaning
A for loop that counts down: start i high, keep going while i >= 1, and subtract 1 each time with i--. Use i -= 2 to count down in steps of 2.
Practice
for (let i = 10; i >= 1; i--) {
Testing
Gaps
for (let i = ; i >= 1; i--) {
Check Answer
Spots
1console.log("Countdown");
2for (let i=10; i>=1; i++) {

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Penguin' badge — List Waddler, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which for loop counts down from 10 to 1?
A. for (let i = 10; i >= 1; i++)
B. for (let i = 10; i >= 1; i--) ✓
i-- subtracts 1 each time, so i gets smaller. i++ would add 1 and the loop would never stop.
2. A countdown starts at 10 and should stop after printing 1. Which condition is correct?
A. i >= 1 ✓
B. i <= 1
The loop keeps running while i >= 1 is true. With i <= 1 and a start of 10, the condition is false straight away, so the loop never runs.
3. What does this loop print? for (let i = 3; i >= 1; i--) { console.log(i); }
A. 3, 2, 1 ✓
B. 1, 2, 3
i starts at 3 and goes down by 1 each time, so the console shows 3, then 2, then 1.
4. To count down, the starting value of i should be...
A. Low, such as let i = 1
B. High, such as let i = 10 ✓
A countdown starts at the biggest number and moves down towards the smallest.
5. Which update makes a for loop count down in steps of 2?
A. i -= 2 ✓
B. i += 2
i -= 2 subtracts 2 from i each time. i += 2 adds 2, which makes the number go up.

Match the Pairs

for (let i = 10; i >= 1; i--) → Counts down from 10 to 1, taking away 1 each time the loop repeats
for (let i = 10; i >= 0; i -= 2) → Counts down from 10 to 0 in steps of 2: 10, 8, 6, 4, 2, 0
To count down, the loop condition must use >= so the loop keeps running while the counter is still at or above the last number → for (let i = 10; i >= 1; i--) { console.log(i); }
A countdown loop updates the counter by subtracting, so the counter gets smaller every time → for (let i = 10; i >= 1; i--)
for (let i = 10; i >= 1; i++) → The update i++ adds 1, so the counter goes up away from 1 and the loop never ends. It should be i--.
for (let i = 10; i <= 1; i--) → The condition i <= 1 is false straight away because 10 is not less than or equal to 1, so the loop never runs. It should be i >= 1.

Key Term

for (let i = 10; i >= 1; i--)
A for loop that counts down: start i high, keep going while i >= 1, and subtract 1 each time with i--. Use i -= 2 to count down in steps of 2.

Fill in the Blanks

1. for (let i = 10; i >= 1; i--) { console.log(i); }
Hint: Type the high number the counter starts at so the countdown begins at the top.
2. for (let i = 10; i >= 1; i--) { console.log(i); }
Hint: Type the comparison operator that keeps looping while i is greater than or equal to 1.
3. for (let i = 10; i >= 1; i--) { console.log(i); }
Hint: Type the update that subtracts 1 from the counter after each loop.
4. for (let i = 10; i >= 1; i -= 2) { console.log(i); }
Hint: Type the shorthand operator that subtracts the step size from i each time.
5. for (let i = 10; i >= 1; i--) { console.log(i); }
Hint: Type the loop counter variable so each countdown number is printed.

Spot the Error

Question 1
A console.log("Countdown");
B for (let i=10; i>=1; i++) {
C console.log(i);
D }
Line B — i++ adds 1 each time, so i goes up (11, 12, ...) and i >= 1 stays true forever. A countdown must use i-- to subtract 1 each time.
Question 2
A for (let i=1; i>=10; i--) {
B console.log(i);
C }
Line A — A countdown must start high. Starting at 1 makes i >= 10 false straight away, so the loop never runs. It should be let i=10 and i>=1.
Question 3
A let count = 0;
B for (let i=10; i>=1; i--) {
C count--;
D }
E console.log(count);
Line C — The loop runs 10 times, and count should go up by 1 each time with count++. Using count-- would give -10 instead of 10.
Question 4
A let total = 0;
B for (let i=10; i>=1; i--) {
C total += i;
D console.log(totl);
E }
Line D — The variable is spelled total. Writing totl causes a ReferenceError because that name was never created.
Question 5
A console.log("Evens down");
B for (let i=10; i>=2; i-=2) {
C console.log("i");
D }
Line C — Quotes make "i" a piece of text, so the letter i prints every time. Remove the quotes to print the counter value: console.log(i);

Student with a class code? Join your class →