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