Loops

Get an overview of loops, and learn how while and do-while loops work.

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.

Get hands-on with 1200+ tech skills courses.