Great job! In this lesson, we learned how to write cleaner code with loops. You now know:
- Loops perform repetitive actions so we don’t have to code that process manually every time.
- How to write
forloops with an iterator variable that increments or decrements
- How to use a
forloop to iterate through an array
- A nested
forloop is a loop inside another loop
whileloops allow for different types of stopping conditions
- Stopping conditions are crucial for avoiding infinite loops.
do...whileloops run code at least once— only checking the stopping condition after the first execution
breakkeyword allows programs to leave a loop during the execution of its block