JS Coding Questions Logo
JS Coding Questions
#144💼 Interview💻 Code

What are break and continue statements

Advertisement

728x90

The break statement is used to "jump out" of a loop. i.e, It breaks the loop and continues executing the code after the loop.

javascript
1for (i = 0; i < 10; i++) {
2  if (i === 5) {
3  break;
4  }
5  text += "Number: " + i + "<br>";
6  }

The continue statement is used to "jump over" one iteration in the loop. i.e, It breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

javascript
1for (i = 0; i < 10; i++) {
2  if (i === 5) {
3  continue;
4  }
5  text += "Number: " + i + "<br>";
6  }

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 59

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
144of476