← JavaScript Coding

Sequential Async

medium

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.

Premium

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
Unlock the full solution →

Already a member? Log in to open the workspace.

More JS Coding questions

View all JS Coding →
JS CodingEasy

City Fetcher API

JS CodingHard

promise.all( )

JS CodingHard

promise.allSettled( )

JS CodingHard

promise.any( )

JS CodingHard

promise.race( )

JS CodingEasy

promise.reject()

Explore related prep hubs

  • All JavaScript coding
  • JavaScript interview questions
  • JS polyfill interview questions
  • Debounce & throttle questions
  • React interview hub