Created
January 19, 2022 21:48
-
-
Save joshdance/10ede5ee0e59c8bb2881ea7b06c05141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arrowTenPromise = new Promise((resolve, reject) => { | |
let importantNumber = 11; | |
if (importantNumber == 10) { | |
resolve('Success using arrow functions, so we call resolved for the promise.'); | |
} else { | |
reject('Rejected because important number is not equal to 10'); | |
} | |
}); | |
arrowTenPromise.then(function(result) { | |
console.log(result); | |
}).catch( (error) => console.log(error)); | |
const nonArrowTenPromise = new Promise(function callbackButYouCanNameItWhateverYouLike(resolve, reject) { | |
let importantNumber = 10; | |
if (importantNumber == 10) { | |
resolve('Success, so we call resolved for the promise.'); | |
} else { | |
reject('Rejected because important number is not equal to 10'); | |
} | |
}); | |
nonArrowTenPromise.then(function(result) { | |
console.log(result); | |
}).catch(function (error) { | |
console.log(error); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment