WorksheetsJavaScript Functions Quiz
Total questions: 15
Worksheet time: 8mins
What keyword is used to declare a function in JavaScript?
def
func
function
declare
What are the curly braces { } used for in a function?
To define parameters
To enclose the code block
To call a function
To return values
Which of the following is the correct way to call a function?
function name;
name();
call.name();
function();
What are parameters in a JavaScript function?
Reserved keywords
Variables that hold input values
Return statements
Function names
How are multiple parameters separated in a function definition?
Semicolons (;)
Curly braces { }
Commas (,)
Spaces
What happens when JavaScript reaches a return statement in a function?
The function continues running
The function stops executing
The function loops again
The function deletes variables
Which type of function box ensures the user receives important information?
Prompt box
Confirm box
Alert box
Message box
Which function box allows users to input values before entering a JS-enabled page?
Confirm box
Prompt box
Alert box
Message box
If the user clicks Cancel in a prompt box, what value is returned?
true
false
null
empty string
How many parameters does a prompt box accept?
1
2
3
Unlimited
What is the purpose of the confirm box?
To display a message only
To verify or accept an action
To create a loop
To return string values
What does a confirm box return if the user clicks OK?
false
true
null
string
Which symbol is used to add a line break in an alert box?
/n
//n
\n
/br
Which of the following is a benefit of using functions?
They slow down execution
They prevent reusability
They allow code reusability
They only work once
What is required after a function’s name when defining or calling it?
Square brackets [ ]
Parentheses ( )
Curly braces { }
Angle brackets
