Conditions are not always met by the simple difference in values of numbers. Conditions are often far more complex than that!

Let’s look at two common ways to create more powerful logical conditions, AND and OR operators.

Something like AND and OR operators allow us to combine conditions. The statements will look like:

  • Condition1 AND Condition2
  • Condtion1 OR Condtion2


An AND condition only passes if both the left and right conditions are true. If either condition is false, the overall statement fails.

So for example :

If (it is cloudy AND the temperature is below 32) { snow }

For this program, if either the sky is clear, or the temperature is too warm, it will not snow. The sky needs to be cloudy AND it needs to be very cold for snow to happen.


The OR condition requires that at least one of two conditions is true for the whole statement to be true.

For example, if we think about our dentist appointments:

If (I am due for a cleaning OR I have a toothache) { go to the Dentist }

We don’t need multiple reasons to go to the dentist. We might go if it is time for our regular cleaning OR we might go because there is a problem. If both conditions were met, we’d have even more reason to go!

The logical operators allow us to combine conditions into more complex expressions. Let’s practice getting Codey home.


Codey’s stuck in a weird shaped tunnel. There’s sometimes bushes to the left of them, or sometimes bushes to the right. Can you navigate Codey to the goal?


Move Codey down if there are hedges to the left or right. Otherwise, move right.

While program is running If Space left is hedge Or Space Right is hedge Move down Else Move right

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?