Loops
Get an overview of loops, and learn how while and do-while loops work.
We'll cover the following...
Computers are great at carrying out repetitive tasks over and over again. They never get bored and will follow the instructions exactly every time. Loops are a way of getting a program to repeat a piece of code according to certain conditions.
What’s a loop?
A loop is a piece of code that will continue to run until a certain condition is met.
To illustrate this, here’s a diagram that shows the countdown to a rocket blastoff as a loop.
Press + to interact
As we can see, we start at , say the number out loud, subtract one from the number and then check to see if we’ve reached zero. If we haven’t reached zero, we loop back and repeat the process over again, so we continue to say the ...