Last active
November 23, 2020 04:18
-
-
Save SidShenoy/6ad5add0ea8b95ee70371d213586b550 to your computer and use it in GitHub Desktop.
Structure of a promise
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
var promise = new Promise(function(resolve, reject){ | |
var goodGift = true; | |
if(goodGift){ | |
// Your promise was reolved! | |
var gift = {"message": "Here is an iPhone12!"} | |
resolve(gift); | |
} | |
else { | |
// Your promise was rejected! | |
var gift = {"message": "Here is a stinky sock!"} | |
reject(gift); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment