Closures interview questions
Practice 39 questions on closures. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
39 questions
- JavaScriptCoding exercise
Cancellable Interval
EASYImplement a setInterval wrapper that returns a function which stops the interval when invoked.
15 minCoinbasePractice - JavaScriptCoding exercise
Cancellable Timeout
EASYImplement a setTimeout wrapper that returns a function you can call to cancel the pending callback.
15 minPractice - JavaScriptCoding exercise
Compose
EASYImplement a function that composes functions right-to-left so the output of each feeds into the next.
15 minPractice - JavaScriptCoding exercise
Cycle
EASYImplement a function that, given several values, returns a function that yields each one in turn and loops forever.
15 minUberPractice - JavaScriptCoding exercise
Debounce
EASYImplement a function that delays invoking another function until a specified period of inactivity has passed.
15 minAdobe · Airbnb · Amazon +26Practice - JavaScriptCoding exercise
Make Counter
EASYImplement a factory that takes a starting integer and returns a function that returns the next value on each call.
15 minAmazon · Robinhood · RobloxPractice - JavaScriptCoding exercise
Number of Arguments
EASYImplement a function that returns the count of arguments passed to it at call time.
15 minPractice - JavaScriptCoding exercise
Once
EASYImplement a function that wraps a callback so it runs at most one time and reuses that result thereafter.
15 minAmazonPractice - JavaScriptCoding exercise
Typewriter Pacer
EASYBuffer bursty streamed text and emit it one character at a time at a steady cadence, with flush and stop controls.
18 minPractice - JavaScriptCoding exercise
useLatest
EASYImplement a hook that returns a ref always holding the newest value, so callbacks and effects can read it without going stale.
15 minPractice - JavaScriptCoding exercise
before / after
MEDIUMImplement before and after — cap how many times a function runs, or delay invoking it until the Nth call.
25 minPremium questionPractice - JavaScriptCoding exercise
Console Log History
MEDIUMImplement a wrapper that intercepts console.log calls and records their arguments for later inspection.
25 minMetaPractice - JavaScriptCoding exercise
Curry
MEDIUMImplement a function that transforms a multi-argument function into a chain of single-argument calls.
25 minAmazon · Intuit · Meta +2Practice - JavaScriptCoding exercise
Curry II
MEDIUMImplement a flexible curry where each call can supply any number of arguments until the original arity is reached.
25 minPremium questionQualcommPractice - JavaScriptCoding exercise
Curry IV
MEDIUMExtend curry with placeholder support, so arguments can be supplied in any position across calls.
40 minPremium questionPractice - JavaScriptCoding exercise
Debounce II
MEDIUMExtend debounce with cancel and flush methods to abort or immediately invoke pending calls.
25 minAirbnb · Flipkart · Google +6Practice - JavaScriptCoding exercise
Debounce III
MEDIUMExtend debounce with a maxWait option that forces a call after a maximum delay even under constant activity.
25 minPremium questionPractice - JavaScriptCoding exercise
Dependency Injection Container
MEDIUMBuild a DI container that resolves a service dependency graph, caches singletons, and detects circular dependencies.
25 minGoogle · Microsoft · UberPractice - JavaScriptCoding exercise
flow
MEDIUMImplement flow — compose functions left to right so each output feeds the next.
25 minPremium questionPractice - JavaScriptCoding exercise
Function.prototype.bind
MEDIUMImplement Function.prototype.myBind — return a new function with a fixed `this` and optional preset arguments.
25 minAdobe · Amazon · Atlassian +3Practice - JavaScriptCoding exercise
Limit
MEDIUMImplement a function that wraps a callback so it runs at most N times and returns the last result thereafter.
25 minPremium questionPractice - JavaScriptCoding exercise
Make Counter II
MEDIUMImplement a factory that returns a counter object with methods to read, increment, decrement, and reset its value.
25 minPremium questionAmazonPractice - JavaScriptCoding exercise
Memoize
MEDIUMImplement a function that caches results of a single-argument function so repeat calls return instantly.
25 minAirbnb · Atlassian · Expedia +5Practice - JavaScriptCoding exercise
Memoize III
MEDIUMExtend memoize with a custom key resolver and cache controls (.clear() and .delete(key)).
25 minPremium questionPractice - JavaScriptCoding exercise
Mini Jotai Atoms
MEDIUMBuild atom-based state with primitive and derived atoms that recompute and notify subscribers on change.
25 minPractice - JavaScriptCoding exercise
Mini Redux
MEDIUMBuild a Redux core with createStore, combineReducers, and applyMiddleware over a subscribe/dispatch loop.
25 minPractice - JavaScriptCoding exercise
negate / overEvery
MEDIUMImplement negate, overEvery, and overSome — build new predicates by combining existing ones.
25 minPremium questionPractice - JavaScriptCoding exercise
partial
MEDIUMImplement partial and partialRight — pre-fill some of a function's arguments, with placeholder support.
25 minPremium questionPractice - JavaScriptCoding exercise
Promisify
MEDIUMImplement a function that wraps a Node-style error-first callback function so it returns a promise.
25 minAmazon · MicrosoftPractice - JavaScriptCoding exercise
Promisify II
MEDIUMExtend promisify so the wrapped function can override the resolved value via a custom override hook.
25 minPremium questionAmazonPractice - JavaScriptCoding exercise
Redux Middleware (Thunk + Logger)
MEDIUMImplement the curried Redux middleware chain with working thunk and logger middleware.
25 minPractice - JavaScriptCoding exercise
Signals (signal / computed / effect)
MEDIUMBuild reactive signals with automatic dependency tracking so computed values and effects update on change.
25 minPractice - JavaScriptCoding exercise
Singleton
MEDIUMImplement a Singleton class that always hands back the same instance no matter how many times you construct it.
25 minPremium questionPractice - JavaScriptCoding exercise
Sum
MEDIUMImplement a curried sum function that accepts numbers one call at a time and returns the running total when invoked with none.
25 minAmazonPractice - JavaScriptCoding exercise
Throttle
MEDIUMImplement a function that limits how often a wrapped function can be invoked within a time window.
15 minAdobe · Amazon · Atlassian +20Practice - JavaScriptCoding exercise
Throttle II
MEDIUMExtend throttle with cancel and flush methods plus leading and trailing edge options.
25 minPremium questionPractice - JavaScriptCoding exercise
useGetState
MEDIUMImplement a useState variant that also returns a getter for reading the newest state from inside stale closures.
25 minPractice - JavaScriptCoding exercise
useTimeout
MEDIUMImplement a hook that runs a callback after a given delay and cleans up when the component unmounts.
25 minPractice - JavaScriptCoding exercise
Curry III
HARDImplement a curry helper that turns a variadic function into one that can be called repeatedly with any number of arguments.
40 minPremium questionQualcommPractice