Learn

We often want to check if a value is above or below a certain amount. We check the relation of one value to another.

These kinds of conditions are known as relational operators. Languages typically use symbols from mathematics:

  • For less than: <
  • For less than or equal to: <=
  • For greater than: >
  • For greater than or equal to: >=

For example, if you go to the doctor and the nurse takes your temperature:

Take patient's temperature If (body temperature is > 99) { Alert doctor to fever } Send in doctor

We can use relational operators to check whether values are higher or lower than each other. With Codey, we will compare their horizontal and vertical positions.

Instructions

Codey is blocked by some hedges again. Can you write a program that lets Codey know when to turn up towards the goal?

Hint
Use the Codey's x position condition to move Codey to the right until Codey aligns with the flag, then move up.
Solution
While program is running If Codey's x position is < 8 Move right Else Move up

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?