Using `continue` in JS
The continue statement is used to skip the rest of the code in the current iteration of a loop (for, while, or do...while) and continue with the next one.
Why use it?
- Avoids excessive nesting of
if. - Makes the code cleaner by "cleaning up" cases that we are not interested in at the beginning of the loop.
- Optimizes readability in filtering loops.
"Remember: in a while loop, make sure to increment your counter before the continue to avoid infinite loops."