Day 47

in code •  7 years ago 

March 1st, 2018

Hello! At the ES6 course by Wes Bos, I learned some more about custom promises.
We reviewed how we can create a custom promise:

function breathe(amount) {
       return new Promise((resolve, reject) => {
    if() {
   reject...
   }

We use reject if we don't want the function to work for some reason. There is an error for example.

 breathe(1000).then(res => {
       console.log(rs);e
       return breathe(500);
    }).then(res => {...

 ....  })catch(err => {
   console.error(err);

if we want to catch an error
Cheers!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!