Sometimes you have an action (or several actions) that should be done only under certain conditions.
![]()
For example, if a fish is at the wall of an aquarium, it needs to change direction before it can move forward.
if ( fish.atWall() == true ) { fish.changeDir(); }Syntax:if ( <boolean-expression> ) { <the conditional statement(s)> }