Compound conditions inside an if
A compound condition joins several tests in one if using && (and), the or operator and ! (not). Brackets set the order. Use it for range checks, like age between 10 and 15.
Understanding Compound conditions inside an if in ACARA Digital Technologies Years 7–8
What it does: The brackets make JavaScript work out the || part first. Without them && is checked before ||, which can change the answer. ! flips a boolean from true to false or false to true. Here the block runs when the score is 50 or more and isAbsent is false. && needs BOTH tests to be true. With ||, every number passes, because any number is either 10 or more, or 15 or less. x > 3 is true, but x < 4 is false. With && one false test makes the whole condition false. || means OR, so only one of the two tests has to be true. It is a good way to catch values outside a range.
Common mistakes: A range check needs both tests to be true, so it must use &&. With ||, every number passes, because every number is at least 10 or at most 15. It should be: if (age >= 10 && age <= 15) {. To test for outside a range, use ||. No temperature can be below 5 and above 35 at the same time, so && is never true. It should be: if (temp < 5 || temp > 35) {.
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 (age >= 10 && age <= 15)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →