Using a returned value
A function call is replaced by the value it returns, so you can store it in a variable, print it or use it in a calculation like square(2) + square(3).
Understanding Using a returned value in ACARA Digital Technologies Years 7–8
What it does: square(4) is replaced by 16, so console.log prints 16 without needing a variable. The call runs and returns 16, but with no variable or console.log the value is thrown away. Each call is replaced by its returned value: square(2) becomes 4 and square(3) becomes 9. Then 4 + 9 = 13. Storing the returned value in a variable keeps it, so you can use big again later in your program. result holds the number 9 that the call returned. The function is not run again when you use result. Both calls belong in one expression: 4 + 25 is stored in total. A semicolon after the first call ends the statement too early.
Common mistakes: Without brackets and an argument, square is not called, so result stores the function itself instead of 16. It should be let result = square(4);. console.log only prints the answer. It does not give a value back, so square(4) returns undefined and result is undefined. It should be return n * n;.
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 611–623) and word search (Modules 611–634).
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
let result = square(4);Fill in the Blanks
Spot the Error
Student with a class code? Join your class →