← ACARA Digital Technologies Years 7–8

Functions with several parameters

Separate several parameters with commas. A call like add(2, 3) must give one argument for each, in the same order. A missing argument becomes undefined.

Understanding Functions with several parameters in ACARA Digital Technologies Years 7–8

What it does: The arguments are in the wrong order, so name gets 12 and age gets "Ava". The call should be say("Ava", 12). Only one argument was given, so a is 5 and b has no value. It becomes undefined, and 5 + undefined gives NaN. Several parameters are separated by commas. Without the comma, JavaScript gives a syntax error. Arguments match parameters in order: the first argument goes to a and the second goes to b. Swapped arguments change the answer. subtract(4, 10) gives -6 because a is 4 and b is 10. The comma between a and b shows the function takes two inputs, so each call needs two arguments.

Common mistakes: The function only has the parameters w and h, so x is not defined. It should be return w * h;. Several parameters must be separated by a comma. It should be function add(a, b) {.

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 583–613) 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
Which function header correctly declares two parameters?
function add(a b) {function add(a, b) {
Matches
function add(a b) { return a + b; }
↓
The parameters a and b are not separated by a comma. It should be add(a, b).
Applying
Meanings
Term
function add(a, b) {
Meaning
Separate several parameters with commas. A call like add(2, 3) must give one argument for each, in the same order. A missing argument becomes undefined.
Practice
function add(a, b) {
Testing
Gaps
add(a, b) {
Check Answer
Spots
1function area(w, h) {
2 return w * x;

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

The 'Giraffe' badge — High Perspective, 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 header correctly declares two parameters?
A. function add(a, b) { ✓
B. function add(a b) {
Several parameters are separated by commas. Without the comma, JavaScript gives a syntax error.
2. What does add(2, 3) do when add is function add(a, b) { return a + b; }?
A. a is 3 and b is 2, so it returns 23
B. a is 2 and b is 3, so it returns 5 ✓
Arguments match parameters in order: the first argument goes to a and the second goes to b.
3. A function is declared as function greet(name, age). Which call gives the arguments in the right order?
A. greet("Mia", 13) ✓
B. greet(13, "Mia")
The first argument goes to name and the second to age. Swapping them puts 13 in name and "Mia" in age.
4. For function subtract(a, b) { return a - b; }, which call gives 10 - 4?
A. subtract(4, 10)
B. subtract(10, 4) ✓
Swapped arguments change the answer. subtract(4, 10) gives -6 because a is 4 and b is 10.
5. For function add(a, b) { return a + b; }, what is the value of b in the call add(5)?
A. undefined ✓
B. 0
A missing argument does not become 0. The parameter becomes undefined, so 5 + undefined gives NaN.

Match the Pairs

function add(a, b) { return a + b; } → Declares a function with two parameters, a and b, separated by a comma
add(2, 3) → Calls add with two arguments: 2 goes to a and 3 goes to b
Order matters: the first argument goes to the first parameter, so swapping arguments can change the result → function say(name, age) { } say(12, "Ava")
If you give too few arguments, the missing parameter is undefined → add(5) // b is undefined
function add(a b) { return a + b; } → The parameters a and b are not separated by a comma. It should be add(a, b).
add(2) → The call gives only one argument for a function with two parameters, so b is undefined. It should be add(2, 3).

Key Term

function add(a, b) {
Separate several parameters with commas. A call like add(2, 3) must give one argument for each, in the same order. A missing argument becomes undefined.

Fill in the Blanks

1. function add(a, b) { return a + b; }
Hint: Type the keyword that starts every function declaration.
2. function add(a, b) { return a + b; }
Hint: Type the name of the second parameter, which is added in the body.
3. console.log(add(2, 3)); // prints 5
Hint: Type the second argument so that the total is 5.
4. function sub(a, b) { return a - b; } console.log(sub(10, 4)); // prints 6
Hint: Type the first argument, which goes to a, so the answer is 6.
5. function show(a, b) { console.log(b); } show(5); // prints undefined
Hint: Type the value a parameter gets when its argument is missing.

Spot the Error

Question 1
A function area(w, h) {
B return w * x;
C }
D console.log(area(4, 3));
Line B — The function only has the parameters w and h, so x is not defined. It should be return w * h;
Question 2
A function add(a b) {
B return a + b;
C }
D console.log(add(2, 3));
Line A — Several parameters must be separated by a comma. It should be function add(a, b) {
Question 3
A function total(price, qty) {
B return price * qty;
C }
D console.log(total(2.5));
Line D — The call gives only one argument for two parameters, so qty is undefined and the answer is NaN. It should be total(2.5, 4).
Question 4
A function subtract(a, b) {
B // take b away from a
C return b - a;
D }
E console.log(subtract(10, 4));
Line C — The order matters. This takes a away from b, so subtract(10, 4) gives -6. It should be return a - b;
Question 5
A function label(first, last) {
B return last + ' ' + first;
C }
D let s = label('Ava', 'Lee');
Line B — The parameters are used in the wrong order, so the name comes out as 'Lee Ava'. It should be return first + ' ' + last;

Student with a class code? Join your class →