Buy Now and unlock this series
$
39
.99
$
24
.99
yours forever
$
39
.99
$
24
.99
Become a Pro and unlock everything
$
24
.99
per month
$
24
.99
What are promises?
Downloads
Become a pro to download code and videos
Starting Code
Final Code
Better JavaScript
24 videos
Course Instructor
Scott Tolinski
- Functions
13M38S - Destructuring
16M46S - Named Parameters
10M29S - Naming Things
15M28S - Immutable & Pure Functions
16M55S - Benefits of Smaller Functions
12M42S - JS & The DOM + MDN Docs
17M36S - Interacting With The DOM
10M51S - JS & The DOM part 3
12M31S - Events addEventListener vs Event Methods
9M43S - setTimeout & setInterval
12M53S - What are promises?
13M59S - Async Await
11M33S - JS Array Methods & map
14M54S - Filter
12M4S - Reduce
6M19S - Other Array Methods
8M4S - This
10M27S - More This
6M3S - Classes
15M55S - So Fetch
11M27S - Async IIFE
8M18S - Modules, Import & Export
8M39S - Where To Go From Here
2M57S
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!