Lancecourse
Courses
How-tos
Blog
Sign In
Sign Up
free
Francais
JavaScript Control Structures and Functions Quiz
Test your knowledge of control structures and functions in JavaScript.
Question 1
What is the output of the following code? let x = 10; if (x > 5) { var x = 20; } console.log(x);
20
10
undefined
error
Question 2
What will the following code output? console.log(2 === "2");
false
true
undefined
NaN
Question 3
What does the "break" statement do in a switch case?
Exits the switch case
Continues to the next case
Throws an error
Returns a value
Question 4
What will be the value of "y" after the following code? let y; if (true) { let y = 5; } console.log(y);
undefined
5
0
NaN
Question 5
Which of the following statements is used to stop a loop?
break
continue
return
stop
Question 6
Which of the following is a higher-order function?
map()
filter()
reduce()
forEach()
Question 7
How are function expressions different from function declarations?
Function expressions are not hoisted, function declarations are hoisted
Function expressions are hoisted, function declarations are not
Both are hoisted
Neither are hoisted
Question 8
What keyword is used to define a function in JavaScript?
function
define
func
method
Question 9
Which loop will always execute at least once?
do...while
for
while
foreach
Question 10
What does the following code return? function add(a, b) { return a + b; } add(5, 10);
15
10
15
5
Answer all the questions then submit.
Submit Answers