Functions that return true or false (JavaScript)
A function that returns true or false can be called right inside an if condition. The if block runs only when the function returns true, like isEven(n) or isValidAge(age).
Understanding Functions that return true or false (JavaScript) in ACARA Digital Technologies Years 9–10
What it does: The comparison and && produce a Boolean, so the function returns it directly without needing an if/else. isEven(n) gives back true or false, so it works as the condition without writing === true. The condition is false, so the if block is skipped. Boolean functions are often named with is, such as isEven or isValidAge, so the call reads like a yes/no question. Without brackets and an argument, isEven is just the function itself and is never called. Always call it as isEven(n). Without return, the comparison result is thrown away. It should be return n % 2 === 0;.
Common mistakes: Dividing by 2 does not test for an even number. Use the remainder operator: return n % 2 === 0; so the function returns true only for even numbers. With || the function returns true for almost any number, so invalid ages pass the if check. Both conditions must hold, so use &&: return age > 0 && age < 120;.
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 681–707) and word search (Modules 629–707).
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 (isValidAge(age))Fill in the Blanks
Spot the Error
Student with a class code? Join your class →