Loop through a block of code, but skip the numbers 2 and 3 using the OR operator - Javascript Statement

Javascript examples for Statement:for

Description

Loop through a block of code, but skip the numbers 2 and 3 using the OR operator

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w  w w .j  ava  2 s  .c  o m*/
    var text = "";
    var i;
    for (i = 1; i < 8; i++) {
        if (i === 2 || i === 3) continue;
        document.getElementById("demo").innerHTML += i + "<br>";
    }
}
</script>

</body>
</html>

Related Tutorials