Remember the square you built — move, turn, move, turn, move, turn, move? You probably thought: there must be a better way than writing this out four times.
There is. It's called a loop, and it's one of the most powerful ideas in all of programming.
A loop says: do this again, n times — or do this forever. One instruction replaces a hundred.
Writing four blocks instead of eight is nice. That's not why loops matter.
Loops matter because of change. Suppose you want your square bigger:
move blocks. Miss one and you get a wonky shape.This is the pattern skill from Chapter 3 paying off. Spot the repetition, name the rule, write it once. Anything written once can be changed once.
5 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.