Lancecourse
Les Cours
Les Tutos
Blog
Se Connecter
S'inscrire
gratis
English
JavaScript Control Structures and Functions Quiz
Test your knowledge of control structures and functions in JavaScript.
Question 1
What does the following code return? function add(a, b) { return a + b; } add(5, 10);
15
10
15
5
Question 2
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 3
What will the following code output? console.log(2 === "2");
false
true
undefined
NaN
Question 4
Which loop will always execute at least once?
do...while
for
while
foreach
Question 5
Which of the following is a higher-order function?
map()
filter()
reduce()
forEach()
Question 6
Which of the following statements is used to stop a loop?
break
continue
return
stop
Question 7
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 8
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 9
What keyword is used to define a function in JavaScript?
function
define
func
method
Question 10
What is the output of the following code? let x = 10; if (x > 5) { var x = 20; } console.log(x);
20
10
undefined
error
Answer all the questions then submit.
Submit Answers