The continue statement in JavaScript

JavascriptWeb DevelopmentObject Oriented Programming

The continue statement is used for jumping over one iteration if a specific condition occurs. If a condition is met, then that iteration is skipped and continued from the next iteration.

Following is the code to implement continue statement in JavaScript −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .result {
      font-size: 20px;
      font-weight: 500;
      color: blueviolet;
<h1>Continue statement in JavaScript</h1>
<div class="result"></div><br />
<button class="Btn">Click Here</button>
<h3>Click on the above button to print even numbers from 1 to 30</h3>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   BtnEle.addEventListener("click", () => {
      for (let i = 1; i < 30; i++) {
         if (i % 2 !== 0) {
         resEle.innerHTML += i + " ";


On clicking the ‘Click Here’ button −

Published on 18-Jul-2020 11:42:51