JavaScript Async Callbacks — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Async Callbacks 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
Pass a callback in
easy10 minWrite a loader that hands its result to a callback.
- 2
Use the error-first pattern
easy10 minCall back with null for the error and a name for the value.
- 3
Report a failure
easy10 minCall back with an error and report it.
- 4
Nest two steps
easy10 minRun one callback inside another and report both results.
- 5
Use a named handler
medium10 minPass a named function as the callback rather than an inline one.
Find the bug(5)
- 1
Fix the result returned instead of passed
easy8 minReturning from inside a timer gives the caller nothing.
- 2
Fix the arguments in the wrong order
easy8 minThe error comes first and the value second.
- 3
Fix the error never checked
easy8 minThe failure is being reported as a success.
- 4
Fix the callback called with brackets
easy8 minPassing callback() hands over its result, not the function.
- 5
Fix the result used outside the callback
easy8 minThe second half is added before the callback has supplied the first.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace