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

Quiz: A Bug in a Nested If

This program should take the dog along the winding path to the goal, but one block is wrong. Click it.

1while (!atGoal()) {
2    if (pathAhead()) {
3        moveForward();
4    } else {
5        if (pathRight()) {
6            turnRight();
7        } else {
8            turnRight();
9        }
10    }
11}
12
Back

7/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.