← ACARA Digital Technologies Years 7–8

Functions calling other functions

A small function that does one job and is called from inside another function, so a big task is built from small, reusable parts.

Understanding Functions calling other functions in ACARA Digital Technologies Years 7–8

What it does: total() calls the helper double() twice and uses each returned value, showing a helper returning a value to its caller. main() calls three small functions that each do one job, so the big task is split into small steps. A helper does one small job and is called from inside another function. Here area calls square. addTwo(5) calls addOne(5) which gives 6. Then addOne(6) gives 7. The main program can read like a plan, such as: let total = getTotal(); showTotal(total);. This helper does exactly one job and returns a value, so other functions can call it and reuse the result.

Common mistakes: The closing bracket after the parameter list is missing. It should be function sumSquares(a, b) {. The function can then call the square() helper twice. A helper that gives a value to another function must use return. console.log only prints, so getName() gives back undefined and welcome() prints Hi undefined. It should be return "Sam";.

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 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.

Learning
Duo
Can a function call another function inside its body?
No. Only code outside functions can call functions.Yes. A function body can contain calls to other functions.
Matches
function showArea(w, h) { console.log(area); }
↓
The helper is named but never called. It needs brackets and arguments: area(w, h).
Applying
Meanings
Term
helper function
Meaning
A small function that does one job and is called from inside another function, so a big task is built from small, reusable parts.
Practice
function addGst(price) {
Testing
Gaps
function four(n) { return (twice(n)); }
Check Answer
Spots
3}
4function sumSquares(a, 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. Can a function call another function inside its body?
A. Yes. A function body can contain calls to other functions. ✓
B. No. Only code outside functions can call functions.
Functions can call other functions. This is how a big task gets built from small parts.
2. Which function is a helper function? function square(n) { return n * n; } function area(side) { return square(side); }
A. square, because area calls it to do a small job ✓
B. area, because it has a longer name
A helper does one small job and is called from inside another function. Here area calls square.
3. Which design follows 'one job per function'?
A. getTotal() adds the prices and showTotal() prints the result ✓
B. doEverything() adds prices, prints, asks for input and checks errors
Small functions with one job each are easier to read, test and reuse.
4. A helper function returns a value. How does the calling function get that value?
A. helper(5) = result;
B. let result = helper(5); ✓
The call helper(5) gives back the returned value, so you can store it in a variable.
5. Which function body correctly calls the helper double()?
A. function quadruple(n) { return double double n; }
B. function quadruple(n) { return double(double(n)); } ✓
A helper is called with its name and brackets, such as double(n). Calls can be nested.

Match the Pairs

function area(w, h) { return w * h; } → A small helper function that does one job: it returns the area of a rectangle.
function showArea(w, h) { console.log(area(w, h)); } → A function that calls the helper area() inside its body and prints the result.
A helper function returns a value, and the calling function uses that value in a calculation. → function total(a, b) { return double(a) + double(b); }
A main program calls several small functions in order, one job each. → function main() { greet(); playGame(); sayBye(); }
function showArea(w, h) { console.log(area); } → The helper is named but never called. It needs brackets and arguments: area(w, h).
function area(w, h) { w * h; } function showArea(w, h) { console.log(area(w, h)); } → The helper area() has no return, so it gives back undefined and showArea prints undefined.

Key Term

helper function
A small function that does one job and is called from inside another function, so a big task is built from small, reusable parts.

Fill in the Blanks

1. function twice(n) { return n * 2; } function four(n) { return twice(twice(n)); }
Hint: Type the name of the helper function defined on the line above, which four() calls.
2. function isEven(n) { return n % 2 === 0; } function show(n) { console.log(isEven(n)); }
Hint: Type the name of the helper that answers true or false, so show() can use its returned value.
3. let name = getName(); let msg = makeGreeting(name); showMessage(msg);
Hint: Type the variable that holds the result from the previous helper call.
4. function sumTwice(a, b) { return twice(a) + twice(b); }
Hint: Type the keyword that sends the combined helper results back to whoever called this function.
5. function entry(age) { if (isAdult(age)) { console.log("In"); } }
Hint: Type the keyword that makes a decision using the true or false value from the helper.

Spot the Error

Question 1
A function square(n) {
B return n * n;
C }
D function sumSquares(a, b {
E return square(a) + square(b);
F }
Line D — The closing bracket after the parameter list is missing. It should be function sumSquares(a, b) {. The function can then call the square() helper twice.
Question 2
A function getName() {
B console.log("Sam");
C }
D function welcome() {
E console.log("Hi " + getName());
F }
Line B — A helper that gives a value to another function must use return. console.log only prints, so getName() gives back undefined and welcome() prints Hi undefined. It should be return "Sam";
Question 3
A function area(w h) {
B return w * h;
C }
D function showArea(w, h) {
E console.log(area(w, h));
F }
Line A — Parameters must be separated by a comma. It should be function area(w, h) {. Then showArea can call area() as a helper.
Question 4
A function sq(n) {return n*n;}
B function sumSq(a, b) {
C return sq(a + b);
D }
Line C — The helper sq() must be called on each number separately and the results added. sq(a + b) adds first and then squares, which gives a different answer. It should be return sq(a) + sq(b);
Question 5
A function big(n) {return n>9;}
B function check(n) {
C if (big) {
D console.log("Big");
E }
F }
Line C — The helper must be called with brackets and an argument. Without them, big is just the function itself and is always truthy. It should be if (big(n)) {

Student with a class code? Join your class →