Search⌘ K
AI Features

Quiz: Create a Smart Button

Explore your understanding of JavaScript logic and variables by completing a quiz that challenges you to create a smart button responsive to user actions. This practice reinforces your knowledge before you build a mini-project applying these concepts in real scenarios.

We'll cover the following...
...
Technical Quiz
1.

Which line of code will correctly respond when a light is ON?

let lightOn = true;
document.getElementById("switch").addEventListener("click", function() {
  // Which of the following lines correctly checks if the light is ON?
  // A, B, C, or D?
});
A.

if ("true") { alert("Light is on!"); }

B.

if (lightOn) { alert("Light is on!"); }

C.

if (lightOn === "true") { alert("Light is on!"); }

D.

if (true) { alert("Light is on!"); }


1 / 3
...