Being able to create loops while coding is an important part of knowing how to code. I’ll show you how to create a square without loops, with loops and how to make many squares with many loops.
Every instruction to write a line and turn is explicitly coded. We notice however that there is repetition in the code. For a square, all we need is to draw one side, turn and repeat the same thing 4 times. With the repeat command, we can see the power of writing code simply.
Both versions draw a square. With repetition, the code is shorter.
It is possible to add more levels of repetition to draw many squares. I added squares of random colors and random side length.
and you get the following result.
The code for the many squares is as follows. It can be viewed using Hopscotch on the iPad.
http://hop.sc/1ftt0Hw