Languages
[Edit]
EN

JavaScript - break statement

0 points
Created by:
Elmer-Li
396

In this article, we would like to show you how to use break statement in JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

for (let i = 0; i < 5; i++) {
  if (i === 3) {
    break;
  }
  console.log(i);
}

The break statement is used to stop the loop if the specified condition occurs. In this case the loop stops when our counter (i) reaches the value of 3.

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join