Thinking in Code
Math · Foundational · Lesson 5 of 9

If This, Then That

Conditions and while loops

An interactive lesson with 7 steps, about 6 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.

What you’ll learn

  • An if block runs only when its condition is true; else covers the other case.
  • A while loop repeats until its condition becomes false.
  • A loop whose condition never changes runs forever.

Steps

  1. A robot with sensors
  2. One program, two grids
  3. Which branch runs?
  4. While loops
  5. Any length of corridor
  6. Follow the path
  7. A fork in the road