Solution: Asynchronous Language Features and Decorators
Review the solutions to the challenges discussed in the previous lesson.
We'll cover the following
Solution: Fixing the order of execution
By adding await
before delayedPromise()
, we ensure that the execution of the function waits for the delayedPromise
function to complete and resolve before moving to the next line of code. This way, the second message is logged after the delayedPromise
function has finished its execution.
Now, when we run the code, it will log the messages in the correct order:
"1. before calling delayedPromise"
-> "2. calling resolve()"
-> "3. after calling delayedPromise"
.
Get hands-on with 1400+ tech skills courses.