Sleep function in JS w/ promises
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)); const main = async () => { console.log('Going to sleep...'); await sleep(2000); console.log('...and we\'re back!'); } main();