# The JavaScript Continue Statement Explained with Examples

**URL:** <https://forum.freecodecamp.org/t/the-javascript-continue-statement-explained-with-examples/15972>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [June 30, 2016, 7:32pm UTC](https://forum.freecodecamp.org/t/the-javascript-continue-statement-explained-with-examples/15972 "2016-06-30T19:32:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [June 30, 2016, 7:32pm UTC](https://forum.freecodecamp.org/t/the-javascript-continue-statement-explained-with-examples/15972/1 "2016-06-30T19:32:37Z")

</div>

## Introduction

The **continue** statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.

```auto
continue;

```

If the **continue** statement is used in a labeled statement, the syntax is as follows:

```auto
continue labelName;

```

In contrast to the **break** statement, **continue** does not terminate the execution of the loop entirely; instead:

- In a `while` loop, it jumps back to the condition.
- In a `for` loop, it jumps to the update expression.

## Examples

The following example shows a `while` loop that has a **continue** statement that executes when the value of **i** is 3. Thus, **n** takes on the values 1, 3, 7, and 12.

```auto
var i = 0;
var n = 0;

while (i < 5) {
  i++;

  if (i === 3) {
    continue;
  }

  n += i;
  console.log (n);
}

```

[Run Code](https://repl.it/C7hx/0)

In the following example, a loop iterates from 1 through 9. The statements between **continue** and the end of the `for` body are skipped because of the use of the **continue** statement together with the expression `(i < 5)` .

```auto
for (var i = 1; i < 10; i++) {
    if (i < 5) {
        continue;
    }
    console.log (i);
}

```

[Run Code](https://repl.it/C7hs/0)

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [August 7, 2017, 1:46am UTC](https://forum.freecodecamp.org/t/the-javascript-continue-statement-explained-with-examples/15972/2 "2017-08-07T01:46:55Z")

</div>

Closed on August 7, 2017, 1:46am UTC


