Debugging

Fix Async Race

mediumdebuggingasyncpromises
0:00

Problem

`fetchInOrder` should return an array of results in the same order as the input promises resolve conceptually — i.e. the order of the inputs. The current implementation relies on resolution order, which is buggy. Fix it so the returned array preserves input order even if later promises resolve first.

Your solution
Test results
Click Run tests to check your solution against the test cases.

About this challenge

Fix Async Race is a medium debugging coding challenge. It tests your ability to read unfamiliar code, find the defect, and fix it without breaking the rest. Write your solution in the editor above, run it against the test cases, and get instant feedback — free, in your browser, no sign-up.

Show a hint & approach (spoiler)

Hint: Use `await Promise.all(promises)` to get resolved values in input order.

Keep practicing

Browse all coding challenges, or build intuition for the underlying concepts with the algorithm visualizers and the developer cheatsheets.