bulbWorks
pluggedIn
lampSwitchIsOn
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 the button at the bottom of the page to change its state.

bulbWorks = false;

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

if (bulbWorks && pluggedIn && lampSwitchIsOn) {
    // then we can turn light on
}

3. Functions contain multiple statements that can run together, and are often called by Events, like when a user clicks a button.