JSFiddle - React, Tailwind, and code Playground

by lbstr

HTML

<ul id="log"></ul>

JavaScript

// print even numbers up to 10
var num = 0;
var isOdd;

while(num < 10) {
    num++;
    
    // if its odd, we don't want to print the number
    isOdd = (num % 2) === 1;
    if (isOdd) {
        // skip the rest of the code in the loop
        // and continue at the next iteration
        // in this example, we are skipping the call to print below
        continue;
    }
    
    print(num);
}








// don't worry about this code
// it just prints arbitrary messages to the page
function print(msg) {
    var log = document.getElementById('log');
    var item = document.createElement('li');
    item.innerHTML = msg;
    
    log.appendChild(item);
}