Javascript Lamp

A high level view of programming

Variables keep track of state or any other data you wish to store in them.


lampIsOn = false;

This program has three variables, two of which need to be true before the light will turn on.

bulbWorks
pluggedIn
lampIsOn

Logic is the decision-making part of your code. It runs code depending on the conditions of your variables.


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

Functions are collections of statements that can be run together, and are often called by Events, like when a user clicks a button.