Break and Continue in Loops
Explore the use of break and continue statements in JavaScript loops. Understand how to skip iterations with continue and terminate loops with break, improving your control over loop execution in your code.
We'll cover the following...
We'll cover the following...
Background
In this lesson, we will learn about the break and continue statements. These statements make it convenient for us to make alterations to iterations of the loop.
Introduction
In JavaScript loops, you can use statements to either skip an iteration or exit the loop using continue or break statements respectively.
Let’s take a look at each.
Continue statement
The continue statement skips one iteration of the loop and goes onto the next. Any instruction followed by the continue st ...
...