← ACARA Digital Technologies Years 9–10

Functions calling other functions

A function can call another function inside its body. Here square() is a helper, so the bigger function stays short and each function does one job.

Understanding Functions calling other functions in ACARA Digital Technologies Years 9–10

What it does: area() calls the helper multiply() inside its body instead of doing everything itself. Every step has one function, and main() runs them in the right order to build the whole program. Functions can call other functions. This is how we build a bigger function from small helpers. Calling square() keeps the bigger function short and lets the helper do one job. Repeating the maths everywhere goes against that idea. Each box in a decomposition becomes its own single-job function. That makes each part easier to test. The steps must run in a sensible order: load the data first, then process it, then show the result. Showing before loading gives wrong output.

Common mistakes: A function is called with round brackets, not square brackets. It should be sq(a), so the helper runs and gives back the square of a. The helper getArea must multiply width by height. Adding them gives the wrong answer for showArea. It should be return w * h;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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.

Learning
Duo
Which function body calls a helper function?
function area(w, h) { return multiply(w, h); }function area(w, h) { return w * h; }
Matches
function hypotenuse(a, b) { return Math.sqrt(square(a) + square(b)) } function square(n) { return n * n } console.log(square);
↓
The helper is not called. Writing square without brackets just refers to the function and does not run it, so no result is shown. It should be square(3).
Applying
Meanings
Term
return square(a) + square(b);
Meaning
A function can call another function inside its body. Here square() is a helper, so the bigger function stays short and each function does one job.
Practice
function square(n) {
Testing
Gaps
const cube = n => n * (n);
Check Answer
Spots
2function sumSq(a, b) {
3 return sq[a] + sq(b);

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cosmic Owl' badge — Comprehension Guru, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which function body calls a helper function?
A. function area(w, h) { return w * h; }
B. function area(w, h) { return multiply(w, h); } ✓
The correct side calls multiply() from inside area(). The other side does the maths itself and calls no other function.
2. True or false: A function can call another function inside its body.
A. True ✓
B. False
Functions can call other functions. This is how we build a bigger function from small helpers.
3. Which is the better way to use a helper in a larger function?
A. return a * a + b * b; // square() is never used
B. return square(a) + square(b); ✓
Calling square() keeps the bigger function short and lets the helper do one job. Repeating the maths everywhere goes against that idea.
4. A decomposition has three boxes: getInput, calculate and showResult. How should the code match it?
A. One function for each box ✓
B. One giant function that does all three jobs
Each box in a decomposition becomes its own single-job function. That makes each part easier to test.
5. Which main function calls the steps in the right order?
A. function main() { load(); process(); show(); } ✓
B. function main() { show(); process(); load(); }
The steps must run in a sensible order: load the data first, then process it, then show the result. Showing before loading gives wrong output.

Match the Pairs

return square(a) + square(b); → The function calls the helper square() twice and adds the results, so square() does the squaring and this function only combines them.
function main() { getInput(); process(); showResult(); } → A main function that calls each step function in order, one per box of the decomposition.
A helper function does one small job, and a larger function calls it to get that job done. → function area(w, h) { return multiply(w, h); }
Each box of a decomposition becomes its own function, and a main function calls them in order. → function main() { readScores(); average(); report(); }
function hypotenuse(a, b) { return Math.sqrt(square(a) + square(b)) } function square(n) { return n * n } console.log(square); → The helper is not called. Writing square without brackets just refers to the function and does not run it, so no result is shown. It should be square(3).
function main() { showResult(); calculate(); getInput(); } → The step functions are called in the wrong order. Input must come first, then the calculation, then showing the result.

Key Term

return square(a) + square(b);
A function can call another function inside its body. Here square() is a helper, so the bigger function stays short and each function does one job.

Fill in the Blanks

1. const square = n => n * n; const cube = n => n * square(n);
Hint: Type the name of the helper function that cube calls inside its body.
2. function setup() { console.log("Ready"); } function main() { setup(); } main();
Hint: Type the name of the step function that main calls. It is the one defined on the first line.
3. const isEven = n => n % 2 === 0; const check = n => isEven(n) ? "yes" : "no";
Hint: Type the helper function that check calls to test the number.
4. const area = (w, h) => w * h; const cost = (w, h, r) => area(w, h) * r;
Hint: Type the operator that combines the helper's area with the rate r to give the cost.
5. const sum = (a, b) => a + b; const mean = (a, b) => sum(a, b) / 2;
Hint: Type the helper function that mean calls to add the two numbers before dividing.

Spot the Error

Question 1
A const sq = n => n * n;
B function sumSq(a, b) {
C return sq[a] + sq(b);
D }
Line C — A function is called with round brackets, not square brackets. It should be sq(a), so the helper runs and gives back the square of a.
Question 2
A function getArea(w, h) {
B return w + h;
C }
D function showArea(w, h) {
E console.log(getArea(w, h));
F }
Line B — The helper getArea must multiply width by height. Adding them gives the wrong answer for showArea. It should be return w * h;
Question 3
A function greet(name) {
B 'Hi ' + name;
C }
D function welcome(name) {
E console.log(greet(name));
F }
Line B — The helper greet has no return keyword, so it gives back undefined to welcome. It should be return 'Hi ' + name;
Question 4
A function main() {
B const s = [70, 85, 90];
C const t = total(s);
D show;
E }
F main();
Line D — Without round brackets the function show is not called, so nothing happens. The step should be called with show(t); so main runs the steps in order.
Question 5
A func cube(n) {
B return n * n * n;
C }
D function boxVol(s) {
E return cube(s);
F }
Line A — The keyword to declare a function is function, not func. The line should be function cube(n) {

Student with a class code? Join your class →