JSFiddle - React, Tailwind, and code Playground

HTML

<pre id="output"></pre>

JavaScript

"use strict";

function sleep(time){ // Defining sleep function
  return new Promise(resolve=>setTimeout(resolve,time)); // Return a promise and resolve it after time time
}

function print(txt){ // For logging stuff
  document.getElementById("output") // Get output element
    .appendChild(document.createTextNode(txt)); // add text node
}

(async function(){ // An anonymus async function
  while(1){ // Endless loop
    print("Hello!\n"); // Print hello
    await sleep(1000); // Wait 1 seconds
    print("World!\n"); // Print world
    await sleep(1000); // Wait 1 seconds
  }
})(); // Execute it right away