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!