How to break one iteration in while loop if a specified condition occurs, and continue with next iteration in JavaScript

1 Answer

0 votes
var i = 0;

while (i < 5) {
    i++;
    if (i === 2) {
        continue;
    }
    document.write("i = " + i + "<br />");
}
 
/*
run:

i = 1
i = 3
i = 4
i = 5

*/

 



answered Apr 20, 2017 by avibootz
...