1. Introduction
After completing this module, you are expected to:
- Control loops with the break and continue statements
- Implement nested loop
In the previous learning module, you learned how to create corresponding loop statements to represent the iterative process and how to use the while, the do while, and the for..in statements to repeatedly execute codes in JavaScript.
In this learning module you will
learn how to control loops with the break
and continue statements, and how to
use nested loops in JavaScript.
JavaScript gives you
more flexibility when it comes to loop statements. There are instances
that you might need to get out of a loop without going all the way to the
bottom. You may also want to skip a part of your code block and go straight to
the next loop iteration. The break and continue statements in JavaScript will
manage these situations. These statements are used to exit a loop immediately
or to begin the next iteration of a loop.