Chapter 7: Comparisons & Boundary Checks
Use <, =, and > operators accurately, including edge cases where two numbers are exactly equal.
Lesson goal & core concept
Prevent off-by-one bugs in score goals, borders, and timers.
Remember that "10 > 10" is false and "10 < 10" is false. Always test what happens right on the boundary number.
Step-by-step practice
Work through these steps in the Scratch editor, predicting each result before clicking the green flag.
- Test whether a sprite crossed the right edge with <(x position) > (220)>.
- Trigger victory when <(score) > (9)> for 10+ integer points.
- Use <(hp) < (1)> instead of <(hp) = (0)> in case HP drops below zero.
- Test boundary values (9, 10, 11) deliberately.
- When green flag clicked
- Forever
- If (x position) 200> then
- Say Finish line!
Try it: Announces the finish line as soon as x passes 200.
Mini challenge & next steps
Build a boundary guard that stops a sprite from walking past x = 210 or x = -210.
FAQ
How long should I spend on "Chapter 7: Comparisons & Boundary Checks"?
Aim for 15–20 minutes: read the concept, test the small example, modify one value to see what changes, and try the mini challenge.
This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.