Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

If, Else

On these maps, the path turns, always to the right, but in different places on each map. So on every tile, the dog has to choose between two options: if there's a path ahead, it moves forward, and otherwise it turns right.

The If … else block chooses between two options. It has two mouths:

  • If path ahead
    • Move forward
  • else
    • Turn right ↻

When the condition is true, the blocks in the upper mouth are carried out. When it's false, the blocks in the lower one, after the word else, are carried out. So exactly one of the two parts is always carried out, never both and never neither.

Put this decision in a Repeat until at the goal loop. On every pass, the dog either moves or turns, and that way it gets all the way to the goal, wherever the path turns.

Instructions

  1. 1

    Get the dog to the goal on all three maps.

Back

2/9

  1. 1. The If Block
  2. 2. If, Else
  3. 3. Which Way at the Corner?
  4. 4. Quiz: One Part per Pass
  5. 5. An If Inside an If
  6. 6. A Path with Bones
  7. 7. Quiz: A Bug in a Nested If
  8. 8. Side Trips
  9. 9. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.