if / else
Executes code based on a condition.
Syntax
if condition { } else { }Description
Condition WITHOUT PARENTHESES, blocks with curly braces. Intermediate conditions are added with else if.
Example
Loading editor…
Expected output
Passed
When to use?
Flow branching.
Common mistakes
- ⚠️ Do NOT put the condition in parentheses; { } are mandatory.