Promises interview questions
Practice 32 questions on promises. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
32 questions
- EASY
Async CountDown Latch
Implement a countdown latch whose wait resolves once countDown has been called the required number of times.
15 minJavaScript - EASY
Promise Waterfall
Run async tasks in sequence, feeding each result into the next, stopping the chain on the first rejection.
15 minJavaScript - EASY
Promise.race
Implement Promise.race so it settles with the outcome of whichever input promise settles first.
15 minJavaScript - EASY
Promise.reject
Implement a function that returns a Promise already rejected with the given reason.
15 minJavaScript - EASY
Sleep
Implement a function that returns a promise resolving after the specified number of milliseconds.
15 minJavaScript - MEDIUM
Abortable Fetch with Timeout
PREMIUMFetch with a timeout that aborts the request via AbortController and honors an external abort signal.
25 minJavaScript - MEDIUM
Array.fromAsync
Implement Array.fromAsync: build a promise of an array from a sync or async iterable, awaiting each value in order.
30 minJavaScript - MEDIUM
Async Debounce (Latest Wins)
Implement an async debounce that resolves only the newest call and discards the results of superseded ones.
25 minJavaScript - MEDIUM
Async Mutex
PREMIUMImplement an async mutex whose acquire returns a release function, serializing access so only one holder runs at a time.
25 minJavaScript - MEDIUM
Async Semaphore
PREMIUMImplement an async semaphore that admits up to N concurrent holders and queues the rest until a permit frees.
25 minJavaScript - MEDIUM
Async Task Queue
PREMIUMImplement a task queue that runs async jobs under a concurrency limit and resolves an idle promise when drained.
25 minJavaScript - MEDIUM
Cancellable Promise
PREMIUMWrap a promise so it can be cancelled — the wrapper rejects on cancel and ignores the underlying settlement.
25 minJavaScript - MEDIUM
Map Async
Implement a function that applies an async mapper to every item in an array and resolves with the results.
25 minJavaScript - MEDIUM
Microtask Batch Scheduler
Coalesce all schedule calls made in one synchronous frame into a single flush on the next microtask.
25 minJavaScript - MEDIUM
Poll Until
Implement pollUntil — call an async function on an interval until a predicate passes or a timeout elapses.
25 minJavaScript - MEDIUM
Promise Merge
Implement a function that combines the results of two promises into a single value using a merger function.
25 minJavaScript - MEDIUM
Promise Pool
Implement a promise pool that runs task factories with a concurrency cap and resolves to their results in order.
25 minJavaScript - MEDIUM
Promise Timeout
Implement a function that races a promise against a timer and rejects if the promise doesn't settle in time.
25 minJavaScript - MEDIUM
Promise.all
Implement Promise.all so it resolves with an array of results or rejects on the first rejection.
25 minJavaScript - MEDIUM
Promise.allSettled
PREMIUMImplement Promise.allSettled from scratch, resolving to an array of fulfilled or rejected outcomes for each input.
25 minJavaScript - MEDIUM
Promise.any
PREMIUMImplement Promise.any so it resolves with the first fulfilled value or rejects with an AggregateError.
25 minJavaScript - MEDIUM
Promise.resolve
Implement Promise.resolve — wrap a value in a fulfilled promise, returning thenables unchanged and adopting their state.
25 minJavaScript - MEDIUM
Promise.withResolvers
Implement Promise.withResolvers — return a new promise alongside its external resolve and reject functions.
25 minJavaScript - MEDIUM
Promisify
PREMIUMImplement a function that wraps a Node-style error-first callback function so it returns a promise.
25 minJavaScript - MEDIUM
Promisify II
PREMIUMExtend promisify so the wrapped function can override the resolved value via a custom override hook.
25 minJavaScript - MEDIUM
Retry with Backoff
Implement retry — re-run a failing async function with a delay that grows exponentially between attempts.
25 minJavaScript - MEDIUM
Singleflight
Implement singleflight so concurrent calls for the same key share one in-flight promise instead of duplicating work.
25 minJavaScript - MEDIUM
useQuery
Implement a hook that tracks the loading, data, and error states of a promise-returning request.
25 minJavaScript - HARD
async parallel / series
PREMIUMImplement Node-style async runners — run error-first tasks in parallel or in series and collect their results.
40 minJavaScript - HARD
Async Read-Write Lock
Implement a read-write lock that allows many concurrent readers or one exclusive writer without starving writers.
40 minJavaScript - HARD
Map Async Limit
PREMIUMImplement an async map that processes an array with a bounded number of in-flight tasks.
40 minJavaScript - HARD
Test Runner IV
PREMIUMExtend a tiny test runner so it correctly awaits asynchronous specs and asynchronous setup or cleanup hooks.
40 minJavaScript