Nested if statements
A nested if is an if inside another if's braces. The inner if is only checked when the outer condition is true. Each if has its own braces and the inner one is indented again.
Understanding Nested if statements in ACARA Digital Technologies Years 7–8
What it does: The inner if has its own { } and sits inside the outer if's { }. The extra indentation shows which block it belongs to. Checking isLoggedIn and then isAdmin inside it gives the same result as combining them with &&, so a nested if can be written as one condition. Each if needs its own pair of braces. The wrong version is missing one closing brace, so the outer block is never closed. x > 5 is false, so the inner if is never checked, even though x > 1 would be true. Both a and b must be true for the code to run. || only needs one of them.
Common mistakes: The console.log call is missing its closing bracket. It should be console.log("Teen"); with the ) before the semicolon. The comparison operator is written backwards. In JavaScript 'greater than or equal to' is >=, not =>, so the outer if should be if (score >= 50) {.
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
if (a) { if (b) { } }Fill in the Blanks
Spot the Error
Student with a class code? Join your class →