Skip to content

Making a choice

Read · 1 of 4

if runs a block only when it's true

if (condition) { … } runs the lines inside the braces only when the condition is true. else { … } runs when it's false.

The condition always goes in round brackets. Indent the lines inside each block so it's easy to see what belongs where.