function delayStep(stepName) { return new Promise((resolve) => { setTimeout(() => { console.log(`${stepName} completed`); resolve(); }, 1000); }); } async function runSteps() { await delayStep("Step 1"); await delayStep("Step 2"); await delayStep("Step 3"); console.log("All steps completed"); } runSteps();
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter