← JavaScript

For Loops

Repeats a block of code a set number of times, using an initializer, condition, and update expression.

Understanding For Loops in JavaScript

What it does: This is the initializer, the first part of the for loop header. A for loop has an initializer, condition, and update, each separated by ;. JavaScript is case-sensitive, so 'for' must be lowercase. The ++ operator adds one to the loop counter each time. They're separated by semicolons ;, not commas. The block of code to repeat is wrapped in { }. The loop starts i at 1, checks i <= 3, and increases i each pass. j-- subtracts one from j each time, counting downward.

Common mistakes: 'for' must be lowercase - a capital F causes an error. The loop header needs parentheses: for (...).

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 11–25) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does a for loop have three parts separated by semicolons?
YesNo
Matches
for let i = 1; i <= 3; i++ { ... }
↓
Wrong - the loop header needs parentheses
Applying
Meanings
Term
for
Meaning
Repeats a block of code a set number of times, using an initializer, condition, and update expression.
Practice
for (let i = 1; i <= 3; i++) {
Testing
Gaps
(let i = 1; i <= 3; i++) {
Check Answer
Spots
1For (let i = 1; i <= 3; i++) {
2console.log(i);

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

The 'Chambered Nautilus' badge — File Explorer, 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. Does a for loop have three parts separated by semicolons?
A. Yes ✓
B. No
A for loop has an initializer, condition, and update, each separated by ;.
2. Must 'for' be written in lowercase?
A. No
B. Yes ✓
JavaScript is case-sensitive, so 'for' must be lowercase.
3. Does i++ increase i by 1 after each pass?
A. No
B. Yes ✓
The ++ operator adds one to the loop counter each time.
4. Can a for loop count down using i--?
A. Yes ✓
B. No
The -- operator subtracts one from the counter each pass.
5. Are the three parts of a for loop separated by commas?
A. No ✓
B. Yes
They're separated by semicolons ;, not commas.

Match the Pairs

for (let i = 1; i <= 3; i++) { ... } → Runs the block 3 times, with i going from 1 to 3
for (let j = 5; j > 0; j--) { ... } → Counts down from 5 to 1, decreasing j each pass
Sets the loop counter's starting value → let i = 1
Increases i by 1 after each pass through the loop → i++
for let i = 1; i <= 3; i++ { ... } → Wrong - the loop header needs parentheses
for (let i = 1, i <= 3; i++) { ... } → Wrong - the parts of a for loop use semicolons, not commas

Key Term

for
Repeats a block of code a set number of times, using an initializer, condition, and update expression.

Fill in the Blanks

1. for (let i = 1; i <= 3; i++) {
Hint: Type the keyword that starts a for loop.
2. for (let i = 1; i <= 3; i++) {
Hint: Type the operator that checks less than or equal to.
3. for (let i = 1; i <= 3; i++) {
Hint: Type the operator that adds one to i after each pass.
4. for (let j = 5; j > 0; j--) {
Hint: Type the operator that subtracts one from j after each pass.
5. for (let k = 0; k < 4; k++) {
Hint: Type the keyword used to declare the loop counter.

Spot the Error

Question 1
A For (let i = 1; i <= 3; i++) {
B console.log(i);
C }
Line A — 'for' must be lowercase - a capital F causes an error.
Question 2
A console.log(i);
B for let i = 1; i <= 3; i++ {
C }
Line B — The loop header needs parentheses: for (...).
Question 3
A let total = 0;
B console.log(total);
C for (let i = 1, i <= 3; i++) {
Line C — The three parts of a for loop are separated by semicolons, not commas.
Question 4
A console.log(i);
B console.log(x);
C console.log(y);
D for (let i = 1; i <= 3; i++) [
Line D — Code blocks use curly braces {}, not square brackets [].
Question 5
A for (let i = 0; i < 5; i++) {
B console.log(i)
C }
Line B — This line is missing a semicolon, but that's not required in JS.

Student with a class code? Join your class →