JSFiddle - React, Tailwind, and code Playground

by johnsonjo4531

JavaScript

const timeout = ms => new Promise(res => setTimeout(res, ms));

  (async () => {
  	const startTime = Date.now();
    const first = timeout(1000);
    const second = timeout(500);
    const third = timeout(800);
   	await first;
    await second;
    await third;
    document.write(`Function completed in ${Date.now() - startTime} ms`)
    console.log(`Function completed in ${Date.now() - startTime} ms`)
  })();