Loops and Ranges
Continue in Loops
Skip the rest of one iteration.
Continue in Loops
continue_loop.js
const skip = 2;
let total = 0;
for (let i = 1; i <= 5; i += 1) {
if (i === skip) {
continue;
}
total += i;
}
console.log("skip=" + skip);
console.log("total=" + total);
continue-loop
`continue` skips to the next iteration. It is useful when one value should not participate in the rest of the loop body.