bulbWorks
pluggedIn
lampSwitchOn
lampIsOn

Javascript Lamp

A high level view of programming. Open the DevTools console to see the more.

1. Variables store data to let you manage state. For example, you can keep track of whether a variable called bulbWorks is true or false.

Click to change its state.

bulbWorks = false; 

2. Events, like when a user clicks a button, can execute Functions containing multiple statements that run together.

Click to change the state of pluggedIn.

pluggedInBtn.addEventListener("click", () => {
    pluggedIn = !pluggedIn; // change to opposite value 
    updateDisplay(); // another function!            
});

3. Logic is the decision-making part of your code. It runs other code depending on the state of your variables. This program has three variables, two of which need to be true before the light will turn on.

Click to change its state.