Skip to Content
Learn
Learn Go: Conditionals
What are Conditionals?

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 true or false), executes an appropriate block of code in response.

In this lesson we’ll cover:

  • if, else if, and else statements.
  • comparison operators.
  • logical operators.
  • the switch statement.
  • 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!

Instructions

Are you thinking about moving on to the next exercise? What conditions are you waiting for?

Folder Icon

Take this course for free

Already have an account?