for (let number = 1; number <= 5; number += 1) {
if (number === 3) {
continue;
}
console.log(number);
}At value 3, console.log is skipped; the loop continues with 4 and 5.
LESSON 26 OF 50
Do not print 3, but continue with later values.
continue ends the current iteration and moves to the next loop step. Unlike break, it does not stop the whole loop.
for (let number = 1; number <= 5; number += 1) {
if (number === 3) {
continue;
}
console.log(number);
}At value 3, console.log is skipped; the loop continues with 4 and 5.
if (number === 3) { break; }break would stop the entire loop, so 4 and 5 would not appear.
Print 1, 2, 4 and 5; use continue when number is 3.
Run the code to see the result.continue skips only the printing of 3, while the loop update keeps it moving forward.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.