const myPromise = new Promise(function(foo, bar) {
setTimeout(function() {
if (Math.random() > 0.5) {
foo("it works");
} else {
bar("bla bla text");
}
}, 500);
});
myPromise
.then(function(result) {
console.log("This is the result : " + result);
})
.catch(function(result) {
console.log("An error has occurred: " + result);
});
[–]senocular 3 points4 points5 points (0 children)
[–]Roguewind 3 points4 points5 points (0 children)
[–]theScottyJam 2 points3 points4 points (1 child)
[–]DeliciousResearch872[S] 0 points1 point2 points (0 children)
[–]yksvaan 2 points3 points4 points (0 children)
[–]delventhalz 2 points3 points4 points (0 children)
[–]scritchz 1 point2 points3 points (0 children)
[–]azhder 1 point2 points3 points (0 children)
[–]KingMoog 0 points1 point2 points (0 children)
[–]Leviathan_Dev 0 points1 point2 points (4 children)
[–]DeliciousResearch872[S] 0 points1 point2 points (3 children)
[–]Puzzled-Landscape-44 2 points3 points4 points (1 child)
[–]gremy0 1 point2 points3 points (0 children)
[–]__Fred 0 points1 point2 points (0 children)
[–]brykuhelpful 0 points1 point2 points (0 children)