promise-4

const tasks = [
  { name: 'task-1', time: 200 },
  { name: 'task-2', time: 400},
  { name: 'task-3', time: 100},
  { name: 'task-4', time: 50}
];

function getPromise(task) {
  const taskPromise = new Promise((resolve, reject) => {
    console.log(task.name + " started.");
    
    setTimeout(() => {
      console.log(task.name + " done in ", task.time, "ms.");
      resolve(task.name);
    }, task.time);
  });
  
  return taskPromise;
}

getPromise(tasks[0]).then(() => getPromise(tasks[1]));