Plan B with else
An if runs code when its condition is true. Add an else block and you also handle the case when it's false. Exactly one of the two blocks runs:
if (condition) {
// runs when true
} else {
// runs when false
}Choosing between many options
Chain else if to test several conditions in order. p5 checks them top to bottom and runs the first one that's true:
TIP
Order matters: put the most specific or highest conditions first, since the first true branch wins and the rest are skipped.