else if chain versus separate if statements
In an else if chain, only the first true branch runs and the rest are skipped. Separate if statements are each checked, so more than one can run.
Understanding else if chain versus separate if statements in ACARA Digital Technologies Years 7–8
What it does: Each if is checked on its own, so a young member gets both discounts. The chain picks exactly one message because later branches are skipped after a match. Once one condition in the chain is true, JavaScript runs that branch and skips the rest of the chain. A chain guarantees only one grade is chosen. Separate ifs could give a mark more than one grade. The two checks are independent, so each needs its own if. A chain would skip the second check after the first was true. Fix it by making the second test a separate if so both conditions are checked and both can run.
Common mistakes: An else if must continue an existing if. Starting the chain with else if is a syntax error. The first test should be a plain if (temp > 30) {. Writing a plain if here makes it a separate check, so both big and mid go up when n is 8. The chain should use else if (n > 3) so that only the first true branch runs.
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
else ifFill in the Blanks
Spot the Error
Student with a class code? Join your class →