JAVASCRIPT CLIMBSChapter 2 · JS Conditionals & Logic
JavaScript If & Else
An if statement evaluates a condition in parentheses. If True, it executes the block in curly braces. An optional else block runs if the condition is False.
Worked example
How it reads
- if (isRainy) checks if the condition inside parentheses is true
- Curly braces {} group the statements to execute for each branch

Cloud tip: Unlike Python, JavaScript does not rely on indentation to find blocks; it uses curly braces. But keep your code indented for readability.


