1 of 2

Conditional statements

2 of 2

> Decision-making statement that checks if a certain condition is true or false and then performs actions based on the result.

  • if statement: Checks a condition. If it’s true, do something. If it’s false, nothing happens.

Eg: if health()<50

……goto healthZone

  • if-else statement: Checks a condition. If it’s true, do one thing; if it’s false, do something else.

Eg: if bananas[1].rotten()

….say “Yuck”

else

….goto bananas[1]