Go Pro Sign Up Login

Buy Now and unlock this series

$

39

.99

$

24

.99

yours forever

Become a Pro and unlock everything

$

24

.99

per month

What are promises?

Downloads

Become a pro to download code and videos

Starting Code

Final Code

Comments

Matt

over 2 years ago [edited]

Found this example on youtube which is very similar to yours just more explicit with what is going on that I thought I would share.

```let p = new Promise((resolve, reject) => { let a = 1 + 4; if(a == 2){ resolve('Promise is resolved') } else { reject('The promise is rejected') } })

p.then((result) => { console.log(result); }) .catch((err) => { console.log(err) })```

So in this example you can just play with the variable a to change how it executes.

Want to join the conversation?

Become a Pro member today!