Promises Continued
// 2nd promise
var playDate = function (gift) {
return new Promise(
function (resolve, reject) {
var message = "Salutations fellow child I enjoy interacting with! I notice you received a posable plastic Batman figurine during the Yultide season. What do you think of my new " + gift.brand + ' ' + gift.item + '?';
resolve(message);
}
);
};
// Promise call
var checkTwice = function () {
console.log('before Christmas'); // log before
iCanHasGift
.then(playDate)
.then(function (fulfilled) {
console.log(fulfilled);
})
.catch(function (error) {
console.log(error)
});
console.log('after opening gifts'); // log after
}
checkTwice()Last updated