Record the three steps in order.
Acceptance criteria
- 1.#out should show trying caught cleaned up.
JavaScript Tutorial · JavaScript Errors
These 10 tasks go with the JavaScript finally chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “finally runs whether the code succeeded or failed.” Read the chapter.
1.Clean up after a failureexercise · easy · 10 min
Record the three steps in order.
Passes when: #out should show trying caught cleaned up.
2.Clean up after successexercise · easy · 10 min · practice plan
Show that finally runs when nothing failed.
Passes when: #out should show worked cleaned up.
3.Clear a loading flagexercise · easy · 10 min · practice plan
Turn the flag off whatever happens.
Passes when: #out should show finished.
4.Run before a returnexercise · easy · 10 min · practice plan
Show that finally runs even when the try block returns.
Passes when: #out should show finally still ran.
5.Use finally without catchexercise · medium · 10 min · practice plan
Clean up but let the error keep travelling.
Passes when: #out should show cleaned and escaped.
6.Fix the cleanup repeated in both branchesbug fix · easy · 8 min
finally does the job once instead of twice.
Passes when: #out should show 2 steps.
7.Fix the cleanup skipped on failurebug fix · easy · 8 min · practice plan
Cleanup placed in the try block is skipped when it throws.
Passes when: #out should show finished.
8.Fix the return from finallybug fix · easy · 8 min · practice plan
A return in finally overrides the one in try.
Passes when: #out should show from try.
9.Fix the order recorded wronglybug fix · easy · 8 min · practice plan
finally runs last, after the catch.
Passes when: #out should show trying caught cleaned up.
10.Fix the error swallowed by finallybug fix · easy · 8 min · practice plan
The inner block should clean up but still let the error escape.
Passes when: #out should show cleaned and escaped.
Between them these tasks cover finally, Cleanup and Control flow.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.