JS TutorialLesson #27

JavaScript Continue

The continue statement skips the current iteration in a loop.

The Continue Statement

The continue statement skips the current iteration in a loop.

The remaining code in the iteration is skipped and processing moves to the next iteration.

.

Example

Example Code

javascript
Try it Yourself
for (let i = 1; i  ";

}

JavaScript Labels

A label provides a name for a statement, or a block of statements, allowing statements to be referenced to, for program flow control, particularly in loops.

Syntax

Example Code

javascript
Try it Yourself
labelname: statement;

Continue to Labelname

Syntax

Example Code

javascript
Try it Yourself
continue labelname;

Example

```javascript let text = "";

loop1: for (let j = 1; j break and continue > are the only JavaScript statements that can "jump out of" a code block.

Interactive Code Examples

JS Example 1

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
for (let i = 1; i < 10; i++) {

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

    text += "The number is " + i + "<br>";

}

Syntax

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
labelname: statement;

Syntax

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
continue labelname;

JS Example 4

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
let text = "";



loop1: for (let j = 1; j < 5; j++) {

  loop2: for (let i = 1; i < 5; i++) {

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

    text += i;

    }

}

JS Example 5

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
let text = "";



loop1: for (let j = 1; j < 5; j++) {

  loop2: for (let i = 1; i < 5; i++) {

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

    text += i;

    }

}