Day 47

in #code6 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!

Coin Marketplace

STEEM 0.23
TRX 0.12
JST 0.029
BTC 66972.83
ETH 3505.42
USDT 1.00
SBD 3.18