How to use Continue Statement in JavaScript Program

Program to use Continue Statement JavaScript Language


let a;
let b = 5;
for (a = 0; a <= 10; a++) {

    if (b == a) {
        continue;
    }
    console.log("Number =",a);

}

Output


Number = 0
Number = 1
Number = 2
Number = 3
Number = 4
Number = 6
Number = 7
Number = 8
Number = 9
Number = 10

Steps Description

  1. Declare two variables a and b
  2. Initialize two variables with value of 5 respectively a and b
  3. continue statement works with loop
  4. If the condition is matched in the if statement inside the for loop, the continue statement will not print that condition.
  5. console.log inbuild function to display a variable number