Sequential Async
Problem statement
Implement executeInSeries(functions), which runs an array of async functions one after another.
The second function must not start until the first one has completed. This is different from Promise.all, which starts everything together.
How to approach Sequential Async
The strategy an interviewer expects you to reach for.
Sequential async runs async functions one-after-another — rate limits, ordered migrations, or “don’t stampede the API.” Naive move fns.map(fn => fn()) or Promise.all. Everything starts at once. Where it breaks Order and backpressure disappear. A failure mid-chain should stop later work (unless the prompt says otherwise). The fix Use a for...of loop with await fn() each iteration (or fns.reduce((p, fn) => p.then(fn), Promise.resolve())). Remember: await inside a loop is intentional here — parallelism is the bug. Say this in the interview: I'd await each async function in series with a for-of loop so the next call starts only after the previous promise settles.
The full solution is part of HelloFrontend Pro
The question above is free to read in full. Upgrade to unlock the interactive workspace and the senior-level walkthrough that go with it.
- Runnable editor with the hidden test suite
- Progressive hints that unlock as you get stuck
- Senior-level reference solution with a line-by-line walkthrough
Already a member? Log in to open the workspace.