Search⌘ K
AI Features

Break and Continue in Loops

Explore how to use break and continue statements in JavaScript loops to manage flow control. Understand how continue skips iterations while break exits loops, improving your ability to write efficient looping code.

Background

In this lesson, we will learn about the break and continue statements. These statements make it convenient for us to make alterations to iterations of the loop.

Introduction

In JavaScript loops, you can use statements to either skip an iteration or exit the loop using continue or break statements respectively.

Let’s take a look at each.

Continue statement

The continue statement skips one iteration of the loop and goes onto the next. Any instruction followed by the continue st ...

...