. Dealing with the Callback Hell situation using Promise. Exploring the different ways of

PHOTO EMBED

Tue Apr 22 2025 18:28:15 GMT+0000 (Coordinated Universal Time)

Saved by @fsd

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");
    });
  
content_copyCOPY