Day 47

in #code7 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.25
TRX 0.19
JST 0.036
BTC 93397.76
ETH 3352.57
USDT 1.00
SBD 3.86