JSFiddle - React, Tailwind, and code Playground

JavaScript

function sleep (duration) {
    var end = new Date().getTime() + duration;
    
    while(new Date().getTime() < end) {
      console.log('sleeping');
    }
}


console.log('start: ' + (new Date().toString()));
sleep(1000);
console.log('end: ' + (new Date().toString()));