Skip to content

Making decisions

Read · 1 of 4

if … else

if (condition) { … } runs the code in braces only when the condition is true.

Add else { … } for what to do otherwise. Exactly one of the two blocks runs, then the program carries on below.