break out of a loop

suggest change

Breaking out of a while loop

var i = 0;
while(true) {
    i++;
    if(i === 42) {
        break;
    }
}
console.log(i);

Expected output:

42

Breaking out of a for loop

var i;
for(i = 0; i < 100; i++) {
    if(i === 42) {
        break;
    }
}
console.log(i);

Expected output:

42

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents