All lessons

Making Decisions

7 min · JavaScript

Run different code depending on whether something is true.

JavaScript · Making Decisions0/5 cleared

Enemy 1 of 5

An if statement runs the code in its { } block only when the condition is true. Compare values with > , < , and === (three equals signs).

Add an else for what happens otherwise. Exactly one block runs.

You
Syntax Skeleton

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Cold