isLoggedIn = true
"Welcome!"
"Log in"
if (isLoggedIn) {
    console.log("Welcome!");
} else {
    console.log("Log in");
}

If / Else

The most basic way to make decisions. If a condition is true, do this. If not (else), do that.

Else If Ladder

For more than two choices, use 'else if'. Code checks each condition in order until one is true.

Switch Statement

When you have many possible values for a single variable, a 'switch' is cleaner than many 'else if' blocks.

Ternary Operator

A shortcut for simple if/else. 'condition ? true : false'. Great for assigning values based on a condition.

Decision Maker

You can now write code that thinks and chooses paths.
Ready to learn about repeating actions with Loops?

AlgoAnimator: Interactive Data Structures