Preview:
function task1() {
    return new Promise((resolve) => {
      setTimeout(() => {
        console.log("Task 1 done");
        resolve();
      }, 1000);
    });
  }
  
  function task2() {
    return new Promise((resolve) => {
      setTimeout(() => {
        console.log("Task 2 done");
        resolve();
      }, 1000);
    });
  }
  
  task1()
    .then(() => task2())
    .then(() => {
      console.log("All tasks completed");
    });
  
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