Quiz: Create a Smart Button
Explore how to combine variables and conditional logic inside button clicks to create interactive, responsive behavior. This quiz helps reinforce your understanding before applying these skills in a mini project.
We'll cover the following...
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
...