← ACARA Digital Technologies Years 7–8

Calling a function

Calling a function: write its name followed by brackets, like sayHello(), to run its code. You can call it as many times as you like. Without the brackets, it does not run.

Understanding Calling a function in ACARA Digital Technologies Years 7–8

What it does: Each call runs the function's code again, so writing the call two times runs it two times. Here the function is declared first, and then it is called with brackets so it runs and prints Hi! Calling sayHello() inside the loop runs it on every repeat. Without the brackets, nothing happens. Brackets are what trigger the call. Without the brackets, the name only refers to the function. The brackets are what run it.

Common mistakes: Line 3 has no brackets, so the function is not called and nothing prints. It should be sayHello(); and it works even before the declaration. The function name is spelled wrongly on line 1, so JavaScript can't find it (ReferenceError). It should be sayHello();.

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 599–610) 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.

Learning
Duo
Which line runs the function sayHello?
sayHello;sayHello();
Matches
sayHello;
↓
The brackets are missing, so the function is not called and its code does not run. It should be sayHello();
Applying
Meanings
Term
functionName()
Meaning
Calling a function: write its name followed by brackets, like sayHello(), to run its code. You can call it as many times as you like. Without the brackets, it does not run.
Practice
function sayHello() {
Testing
Gaps
();
Check Answer
Spots
2sayHello();
3sayHello;

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

The 'Leopard' badge — Savannah Perfectionist, 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 line runs the function sayHello?
A. sayHello(); ✓
B. sayHello;
Brackets after the name call the function. Without them, you only mention the function and nothing runs.
2. A function is declared but never called. What happens to its code?
A. It does not run ✓
B. It runs once automatically
Declaring a function only saves the code. It runs when you call it.
3. After declaring function sayHello(), you write sayHello(); three times. How many times does it run?
A. 1 time
B. 3 times ✓
Each call runs the function's code again, so three calls means three runs.
4. Which is correct? A function declaration is written first, then the call comes below it.
A. function sayHello() { console.log('Hi'); } sayHello(); ✓
B. function sayHello() { console.log('Hi'); } sayHello
The call needs brackets. The version without brackets never runs the code.
5. True or false: in JavaScript, you can call a function before its declaration appears in the file.
A. False
B. True ✓
Function declarations are hoisted, so a call placed above them still works. Writing the declaration first is usually easier to read.

Match the Pairs

sayHello(); → Calls the function sayHello, so the code inside it runs once
for (let i = 0; i < 3; i++) { sayHello(); } → Calls sayHello three times by placing the call inside a loop
You can call the same function twice to run its code twice → sayHello(); sayHello();
A function must be declared before it is called, or its declaration must be available when the call runs → function sayHello() { console.log('Hi!'); } sayHello();
sayHello; → The brackets are missing, so the function is not called and its code does not run. It should be sayHello();
for (let i = 0; i < 3; i++) { sayHello; } → The call inside the loop has no brackets, so sayHello never runs three times. It should be sayHello(); inside the loop.

Key Term

functionName()
Calling a function: write its name followed by brackets, like sayHello(), to run its code. You can call it as many times as you like. Without the brackets, it does not run.

Fill in the Blanks

1. function sayHello() { console.log("Hi!"); } sayHello();
Hint: Type the name of the function being called to run its code.
2. function sayHello() { console.log("Hi!"); } sayHello();
Hint: Type the opening symbol that must follow the function name so the call runs the code.
3. sayHello(); function sayHello() { console.log("Hi!"); }
Hint: Type the keyword that declares a function. The call above it still works.
4. function cheer() { console.log("Go!"); } for (let i = 0; i < 3; i++) cheer();
Hint: Type the loop keyword that calls the function several times.
5. let n = 0; while (n < 2) { sayHello(); n++; }
Hint: Type the loop keyword that keeps calling the function while a condition is true.

Spot the Error

Question 1
A sayHello();
B sayHello();
C sayHello;
D function sayHello() {
E console.log("Hello!");
F }
Line C — Line 3 has no brackets, so the function is not called and nothing prints. It should be sayHello(); and it works even before the declaration.
Question 2
A sayHelo();
B sayHello();
C function sayHello() {
D console.log("Hello!");
E }
Line A — The function name is spelled wrongly on line 1, so JavaScript can't find it (ReferenceError). It should be sayHello();.
Question 3
A for (let i = 0; i < 3; i++) {
B console.log("Round " + i);
C Cheer();
D }
E function cheer() {
F console.log("Go!"); }
Line C — Names are case sensitive. The function is called cheer, not Cheer, so line 3 should be cheer();.
Question 4
A call greet();
B greet();
C function greet() {
D console.log("Hi!");
E }
Line A — JavaScript has no call keyword. To call a function you write its name and brackets only, so line 1 should be greet();.
Question 5
A function sayBye() {
B console.log("Bye!"); }
C sayBye(;
D sayBye();
Line C — The call on line 3 is missing its closing bracket. It should be sayBye(); with both brackets.

Student with a class code? Join your class →