How to use Continue Statement in JavaScript Program

Continue Statement

On this page

Continue Statement

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

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