JavaScript Promise Chaining — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Promise Chaining 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
Chain two steps
easy10 minMultiply a value in one step and report it in the next.
- 2
Build a string across steps
easy10 minAdd a letter in each step and report the result.
- 3
Wait for another promise
easy10 minReturn a promise from a step so the chain waits for it.
- 4
Catch at the end
easy10 minThrow in the middle of a chain and catch it at the end.
- 5
Recover and continue
medium10 minCatch a rejection, return a value, and carry on down the chain.
Find the bug(5)
- 1
Fix the missing return
easy8 minWithout a return the next step receives undefined.
- 2
Fix the nested then
easy8 minNesting rebuilds callback hell; the promise should be returned instead.
- 3
Fix the catch placed too early
easy8 minA catch before the failing step cannot catch it.
- 4
Fix the steps run separately
easy8 minCalling then twice on the same promise does not chain them.
- 5
Fix the value used after the chain
easy8 minThe chain has not finished when the line below runs.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace