if / else
Branching based on conditions.
Syntax
if condition { ... } else { ... }Description
Conditions are written without parentheses; the { } block is mandatory. If true, the first block runs, otherwise the else runs. Intermediate conditions use else if.
Example
Loading editor…
Expected output
Adult
When to use?
Decision making, input control.