// program to print the value of i
for (let i = 1; i <= 5; i++) {
// condition to continue
if (i == 3) {
continue;
}
console.log(i);
}
for (let i = 0; i < 10; i++) {
if (i === 3) { break; }
text += "The number is " + i + "<br>";
}
for (var i = 0; i < 10; i++) {
if (i == 5) { continue; } // skips the rest of the cycle
document.write(i + ", "); // skips 5
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="breakStatementExample()" id="btnClick">Click</button>
<script>
function breakStatementExample()
{
var x;
for ( x=0; x<=15; x++) {
if(x==10)
{
break;
}
if (x === 0)
{
document.write(x +" "+ "is"+" " + "an" + " " + "even number"+ "<br>");
}
else if (x % 2 === 0) {
document.write(x + " "+ "is"+ " " + "an" + " " + "even number"+ "<br>");
}
else {
document.write(x + " "+ "is"+ " " + "a" + " " + "odd number"+ "<br>" );
}
}
}
</script>
</body>
</html>