Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const p = new Promise((resolve, reject) => {
- const age = 17;
- if (age > 18) {
- resolve("I am old enough to ...");
- } else {
- reject("What a shame");
- }
- });
- p.then(function(msg) {
- console.log(msg + " drink !");
- }).catch(function(error) {
- console.log(error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement