We make decisions every day based on certain conditions.
Is the alarm ringing? If so, turn it off. Is it raining? If so, bring an umbrella. Is the ice cream truck parked outside? If so, it’s time for a treat.
We can also implement this decision-making ability in our programs using conditionals. Conditionals check on values and, depending on their status (if the values turn out to be
false), executes an appropriate block of code in response.
In this lesson we’ll cover:
else if, and
- comparison operators.
- logical operators.
- short declarations in conditionals.
- how to use conditionals in randomized conditions.
If you’re ready, Go on to the next exercise. Else, come back when you’re ready!
Are you thinking about moving on to the next exercise? What conditions are you waiting for?