The way to write a loop to make a Jeroo keep hopping until it finds water in front of it is:
So, the condition to keep going is the opposite of the condition to stop!
Fill in the missing conditions to keep each of these loops going. The first example has been filled in for you
Stop the loop when: | the condition to keep going is: |
1. there is water ahead | while(!isWater(AHEAD)) |
2. the Jeroo runs out of flowers | while( ) |
3. the Jeroo is facing South | while( ) |
4. it is clear to the left | while( ) |