Functions – Parameters

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Functions – Parameters

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Do function parameters let you pass values into a function?
A Yes
B No
2. Are multiple parameters separated by commas?
A No
B Yes
3. Is a parameter treated as a variable inside the function?
A Yes
B No
4. Is (a b) valid syntax for declaring two parameters?
A No
B Yes
5. Must parameters be listed inside the function's parentheses?
A No
B Yes

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1function greet(name) { ... } AWrong - multiple parameters need a comma between them
2function add(a, b) { ... } BDeclares a function that accepts two parameters, a and b
3Holds the value passed in when a function is called CWrong - 'function' must be lowercase
4Separates multiple parameters in a function declaration Dname
5function add(a b) { ... } E,
6Function greet(name) { ... } FDeclares a function that accepts a name parameter

Definitions

parameter

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
function greet(____) {
2.
function add(a, _) {
3.
function multiply(x, _) {
4.
console.log(a _ b);
5.
function introduce(____, age) {

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Function greet(name) {
B console.log(name);
C }
Question 2
A function add(a b) {
B console.log(a + b);
C }
Question 3
A function sub(a, b) {
B console.log(a - b)
C }
Question 4
A function mult(x, y) {
B console.log(x * y)
C }
Question 5
A function greet(name) {
B console.log(name);
C ]

Answer Key

Functions – Parameters
Section A: Quick Questions
Q1
A — Yes
Q2
B — Yes
Q3
A — Yes
Q4
A — No
Q5
B — Yes
Section B: Match the Pairs
Q1
function greet(name) { ... } → Declares a function that accepts a name parameter
Q2
function add(a, b) { ... } → Declares a function that accepts two parameters, a and b
Q3
Holds the value passed in when a function is called → name
Q4
Separates multiple parameters in a function declaration → ,
Q5
function add(a b) { ... } → Wrong - multiple parameters need a comma between them
Q6
Function greet(name) { ... } → Wrong - 'function' must be lowercase
Section C: Definitions
Q1
parameter — A named placeholder inside a function's parentheses that receives an input value when called.
Section D: Fill in the Blanks
Q1
function greet(name) {
Q2
function add(a, b) {
Q3
function multiply(x, y) {
Q4
console.log(a + b);
Q5
function introduce(name, age) {
Section E: Spot the Error
Q1
A — 'function' must be lowercase - a capital F causes an error.
Q2
A — Multiple parameters need a comma between them: (a, b).
Q3
B — This line is missing a semicolon, but that's not required in JS.
Q4
B — This line is missing a semicolon, but that's not required in JS.
Q5
C — The block must close with }, not ].