Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Functions Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What keyword is used to declare a function in JavaScript?

a)

def

b)

func

c)

function

d)

declare

2.

What are the curly braces { } used for in a function?

a)

To define parameters

b)

To enclose the code block

c)

To call a function

d)

To return values

3.

Which of the following is the correct way to call a function?

a)

function name;

b)

name();

c)

call.name();

d)

function();

4.

What are parameters in a JavaScript function?

a)

Reserved keywords

b)

Variables that hold input values

c)

Return statements

d)

Function names

5.

How are multiple parameters separated in a function definition?

a)

Semicolons (;)

b)

Curly braces { }

c)

Commas (,)

d)

Spaces

6.

What happens when JavaScript reaches a return statement in a function?

a)

The function continues running

b)

The function stops executing

c)

The function loops again

d)

The function deletes variables

7.

Which type of function box ensures the user receives important information?

a)

Prompt box

b)

Confirm box

c)

Alert box

d)

Message box

8.

Which function box allows users to input values before entering a JS-enabled page?

a)

Confirm box

b)

Prompt box

c)

Alert box

d)

Message box

9.

If the user clicks Cancel in a prompt box, what value is returned?

a)

true

b)

false

c)

null

d)

empty string

10.

How many parameters does a prompt box accept?

a)

1

b)

2

c)

3

d)

Unlimited

11.

What is the purpose of the confirm box?

a)

To display a message only

b)

To verify or accept an action

c)

To create a loop

d)

To return string values

12.

What does a confirm box return if the user clicks OK?

a)

false

b)

true

c)

null

d)

string

13.

Which symbol is used to add a line break in an alert box?

a)

/n

b)

//n

c)

\n

d)

/br

14.

Which of the following is a benefit of using functions?

a)

They slow down execution

b)

They prevent reusability

c)

They allow code reusability

d)

They only work once

15.

What is required after a function’s name when defining or calling it?

a)

Square brackets [ ]

b)

Parentheses ( )

c)

Curly braces { }

d)

Angle brackets