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);

Question 2

What will the following code output? console.log(2 === "2");

Question 3

What does the "break" statement do in a switch case?

Question 4

What will be the value of "y" after the following code? let y; if (true) { let y = 5; } console.log(y);

Question 5

Which of the following statements is used to stop a loop?

Question 6

Which of the following is a higher-order function?

Question 7

How are function expressions different from function declarations?

Question 8

What keyword is used to define a function in JavaScript?

Question 9

Which loop will always execute at least once?

Question 10

What does the following code return? function add(a, b) { return a + b; } add(5, 10);