Loops allow you to execute a block of code repeatedly until a certain condition is met. They are essential for iterating over collections of data or performing tasks multiple times.

5.1. for loop

The for loop is commonly used when you know the number of iterations beforehand.

5.2. while loop

The while loop executes a block of code as long as a specified condition is true. Use it when the number of iterations is unknown.

5.3. do...while loop

Similar to while, but guarantees the code block executes at least once, as the condition is checked after the first execution.

5.4. break and continue statements