JavaScript Asynchronous — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Asynchronous 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
Report the running order
easy10 minUse a timer to build the order first, second, third.
- 2
Show the result is not ready
easy10 minRead a value before the timer sets it and report what you get.
- 3
Use the value where it arrives
easy10 minReport the value from inside the callback, once it exists.
- 4
Show a timer waits its turn
easy10 minEven a delay of zero runs after the current code, so report both in order.
- 5
Count synchronously first
medium10 minFinish a loop, then report from a timer that the loop went first.
Find the bug(5)
- 1
Fix the value read too early
easy8 minThe value is read before the timer has set it.
- 2
Fix the order assumed to be top to bottom
easy8 minThe timer callback runs after the code below it.
- 3
Fix the result expected as a return
easy8 minA function that schedules work cannot return its result.
- 4
Fix the missing report
easy8 minThe timer updates a variable but never shows it.
- 5
Fix the order built in the wrong place
easy8 minThe join happens before the timer has added its entry.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace