Repeat Work Safely
Loops execute a block multiple times. They are essential for processing arrays, retries, and repeated tasks.
Always ensure loops have clear exit conditions to avoid infinite loops.
- Use `for` when you know the number of iterations.
- Use `while` when you loop until a condition changes.
- Use `do...while` when the body must run at least once.