Think of 'if/else' like a fork in a hiking trail with a sign: 'if it's raining, take the covered path; else, take the sunny one.' You always end up walking exactly one path, decided entirely by the condition on the sign.
'if <condition> then' is a C-shaped block that only runs the blocks inside it when a condition (a hexagon-shaped true/false check, like 'touching edge?') is true - otherwise it skips them entirely. 'if <condition> then / else' adds a second mouth that runs instead, whenever the condition is false.
if <condition> then
[runs only if true]
else
[runs only if false]when 🏳️ clicked
if <touching edge?> then
turn ↻ 180 degrees
else
move 10 stepsEvery time this checks, the sprite either turns around (if it's touching the edge of the Stage) OR moves forward (if it isn't) - never both, and never neither. Only one of the two mouths ever runs, decided by the hexagon condition.
Mistake 1: leaving the hexagon slot empty. An if block needs a true/false check dropped in there, or it has nothing to decide with. Mistake 2: dropping a number or text block into the hexagon slot instead. That slot only fits hexagon-shaped blocks - the ones that answer yes or no.
In the app this lesson continues with the animated explanation, spoken aloud, and then the practice: Use an if/else block so your sprite does one thing when a condition is true and something different when it's false. The editor runs your child’s real code and checks the result, with their coding buddy reacting to what they wrote.
Try it free