JavaScript async and await — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript async and await lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Await a promise
easy10 minAwait a resolved promise inside an async function and report the value.
- 2
Await a timer
easy10 minAwait a promise that resolves from a timer.
- 3
Await twice in a row
easy10 minAwait two steps in sequence and report the combined result.
- 4
Await inside a loop
easy10 minTotal three awaited values in a loop.
- 5
Show an async function returns a promise
medium10 minReport whether calling an async function gives back a promise.
Find the bug(5)
- 1
Fix the missing await
easy8 minWithout await you get the promise, not the value.
- 2
Fix the missing async keyword
easy8 minawait only works inside an async function.
- 3
Fix the value read after the call
easy8 minThe async function has not finished when the next line runs.
- 4
Fix the total added before awaiting
easy8 minThe promise itself is being added instead of its value.
- 5
Fix the async function never called
easy8 minDefining an async function does not run it.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace