There are 3 states of the Promise object: Pending: by default, this is the Initial State, before the Promise succeeds or fails. Resolved: Completed Promise Rejected: Failed Promise

PHOTO EMBED

Mon Aug 15 2022 20:12:52 GMT+0000 (Coordinated Universal Time)

Saved by @EMR4HKLMN #javascript

function addName (time, name){
  return new Promise ((resolve, reject) => {
    if(name){
      setTimeout(()=>{
        console.log(name)
        resolve();
      },time)
    }else{
      reject('No such name');
    }
  })
}

addName(2000, 'Joel')
  .then(()=>addName(2000, 'Victoria'))
  .then(()=>addName(2000, 'John'))
  .then(()=>addName(2000, 'Doe'))
  .then(()=>addName(2000, 'Sarah'))
  .catch((err)=>console.log(err))
content_copyCOPY

https://www.freecodecamp.org/news/top-javascript-concepts-to-know-before-learning-react/