call(back)

Problems

Callback's own problems and the LeetCode questions companies have been asking, in one place — pick a category, then filter by company, frequency, status, difficulty, topic, and language.

Debounce

Frontend · Closures and timers, the frontend screen classic.

easySign in to star problems

Build a Counter

Frontend · The React warm-up: state, events, and a derived disable.

easySign in to star problems

Build a Todo List

Frontend · List state done right: keys, controlled input, and deletes.

mediumSign in to star problems

Build Tabs

Frontend · One active index drives the whole component.

easySign in to star problems

Build an Accordion

Frontend · Independent toggles — a Set of open ids, not N booleans.

mediumSign in to star problems

StoreData with Change Listeners

Frontend · A Backbone.Model-style store: two Maps, one event-key normalizer, listeners that can't break each other.

mediumSign in to star problems

Implement a Promise

Frontend · A one-way state machine, a handler queue, and every callback in a microtask.

hardSign in to star problems

Debounce with Cancel and Flush

Frontend · A trailing-edge debounce whose wrapper can also drop the pending call or run it now.

mediumSign in to star problems

Input Validation

Frontend · Declarative rule factories and one message per field — the first failing rule's.

easySign in to star problems

Tabs: initTabs(node)

Frontend · A tab UI packaged as an initializer — two independent instances from one function.

mediumSign in to star problems

Star Rating in a Form

Frontend · Real radio inputs behind the stars: the form submits itself, the keyboard works, N instances are N names.

mediumSign in to star problems

Shuffle and Deal Five Cards

Frontend · Fisher–Yates, a splice, and fresh nodes per deal — the reveal animation comes free.

mediumSign in to star problems

Typeahead with Keyboard Navigation

Frontend · Debounce the query, abort the stale request, cache by query, wrap the arrow keys, wire the combobox.

hardSign in to star problems

Carousel with a Per-Slide Countdown

Frontend · One interval per slide, one batched update per advance — and the double-advance trap.

mediumSign in to star problems

Connect Four

Frontend · Immutable board updates, gravity in dropPiece, and a win check that only looks through the last move.

mediumSign in to star problems

Transfer List

Frontend · Two arrays and one Set of checked ids — get a working version fast, then polish.

mediumSign in to star problems

Implement Array.prototype.flat

Frontend · Depth, holes and Infinity — without recursion, so 100,000 levels can't overflow the stack.

mediumSign in to star problems

Implement Array.prototype.map

Frontend · Pre-size the output so holes stay holes, and forward thisArg.

easySign in to star problems

Run Promises in Sequence

Frontend · Take functions, not promises — then never call the next task until the previous one settles.

mediumSign in to star problems

mapAsync II

Frontend · A sliding window of N workers: results in input order, nothing new after a failure.

mediumSign in to star problems

Create and Consume a Promise

Frontend · A promise that settles after a second, rejecting with an Error — then consumed with await and try/catch.

easySign in to star problems

Inheritance Without class

Frontend · Explain the prototype chain, then rebuild a class ... extends pair from constructor functions, without the new Parent() trap.

easySign in to star problems

Implement cloneDeep

Frontend · Cycles, shared references, Date, RegExp, Map, Set, prototypes and symbol keys: everything spread and JSON get wrong.

mediumSign in to star problems

Implement memoize

Frontend · A closure over a Map keyed on every argument — and has, not truthiness, so 0 and undefined still hit.

mediumSign in to star problems

Implement Lodash's get

Frontend · Read a nested value by path, and return the fallback only when it is missing, never when it is merely falsy.

easySign in to star problems

Implement Lodash's chunk

Frontend · Step by size and slice — after clamping the size, because 0 loops forever.

easySign in to star problems

Key Paths of a Nested Object

Frontend · The dotted path to every primitive in a nested object or array — even when the input has cycles.

easySign in to star problems

Nested Tabs From a Flat List

Frontend · Turn { id, name, parentId } rows into a tree in one pass, then render every level as tabs under its parent.

mediumSign in to star problems

Masonry Layout in CSS

Frontend · Pack cards of different heights into tight columns with CSS alone, then explain what CSS-only masonry cannot do.

mediumSign in to star problems

Load CSS on Demand

Frontend · A promise around a <link>, memoized by href, that forgets failures so a retry can work.

mediumSign in to star problems

Multi-Step Form With a Shared Store

Frontend · Three steps, one reducer: data survives Back, each step validates before Next, and submitting locks the form.

mediumSign in to star problems

Star Rating With Half Stars, at Scale

Frontend · Click to fill, half stars from the click position, a thousand stars, and updates that touch only what changed.

mediumSign in to star problems

Tic-Tac-Toe: N by N, M in a Row

Frontend · A board of any size, a win check that looks only through the last move, and a status line for turn, winner or draw.

mediumSign in to star problems

Six-Digit Code Input

Frontend · Six one-digit fields that feel like one: advance on entry, Backspace back, paste the whole code, lock while verifying.

mediumSign in to star problems

Image Carousel With One Image Element

Frontend · Previous, next and page buttons that wrap around, any aspect ratio fitted to a fixed frame, and a single <img>.

easySign in to star problems

Predict the Output: Promise and Timer Order

Frontend · A promise resolved inside a timer, two more timers, and a microtask: the event loop decides the order.

mediumSign in to star problems

Predict the State: A Redux Reducer

Frontend · Trace three dispatches through a reducer by hand — and read the case labels character by character.

easySign in to star problems

What Is a Closure?

Frontend · A function plus the bindings of the scope it was created in — bindings, not snapshots.

easySign in to star problems

What Is Event Bubbling?

Frontend · Capture down, target, bubble up — and why delegation depends on it.

easySign in to star problems

What Is CORS?

Frontend · Browsers block cross-origin reads unless the server opts in — it protects users, not servers.

easySign in to star problems

Implement groupBy

Frontend · Group items by key into a null-prototype object — because {} already has "constructor".

easySign in to star problems

Implement Array.prototype.filter

Frontend · Skip holes, forward thisArg, and keep the elements whose callback is truthy.

easySign in to star problems

Implement Array.prototype.reduce

Frontend · A missing initial value versus an undefined one — and the TypeError when there's nothing to reduce.

mediumSign in to star problems

Implement Array.prototype.concat

Frontend · Spread arrays and isConcatSpreadable objects one level, keep holes, append everything else.

mediumSign in to star problems

Drive a Generator Like async/await

Frontend · Resume the generator with each resolved value, and throw each rejection back in at the yield.

mediumSign in to star problems

mapAsync I

Frontend · Start every call at once and let Promise.all keep the input order.

easySign in to star problems

Implement Promise.all

Frontend · Store results by index, count down, resolve an empty input at once, reject on the first failure.

mediumSign in to star problems

Promise With a Timeout

Frontend · Race the promise against a timer — and clear the timer when the promise wins.

mediumSign in to star problems

Implement curry

Frontend · Collect arguments until fn.length have arrived — with a fresh array per call so partials stay independent.

mediumSign in to star problems

Implement once

Frontend · A called flag, not a check on the result — and the first call's this and arguments.

easySign in to star problems

A Tooltip Library From data Attributes

Frontend · One tooltip node, delegated listeners, keyboard focus and Escape — in plain DOM, not a component.

mediumSign in to star problems

Predict the Output: What a Spread Copies

Frontend · { ...first } copies the top level only — a nested object stays shared.

easySign in to star problems

Predict the Output: `this` in an Arrow Method

Frontend · An arrow function takes this from where it is defined — and an object literal is not a scope.

easySign in to star problems

Predict the Output: The Temporal Dead Zone

Frontend · A block-scoped const shadows the outer one from the top of its block — before its line runs.

easySign in to star problems

Predict the Output: A then and finally Chain

Frontend · A promise settles once, finally passes values through, and a rejection handler can recover.

mediumSign in to star problems

Predict the Output: var Hoisting With Shadowing

Frontend · A var inside the function is hoisted and initialized to undefined, shadowing the outer one.

easySign in to star problems

Predict the Result: Type Coercion

Frontend · What adding "0" to a number does, and a table of +, == and comparison gotchas.

mediumSign in to star problems

Predict the Output: async/await and the Microtask Queue

Frontend · An async function runs synchronously up to its first await; the rest is a microtask.

mediumSign in to star problems

Predict the Output: var and let in a Loop With Timers

Frontend · var gives the loop one shared binding; let gives each iteration its own.

easySign in to star problems

Predict the Output: Nested Context Providers

Frontend · Default value, nearest provider, and why memo doesn't stop a context update.

mediumSign in to star problems

Which Effect Fetches Data Once on Mount?

Frontend · No dependency array loops, an async effect returns a promise, and a fetch in the render body runs every render.

easySign in to star problems

Which Statement About React Context Is Correct?

Frontend · Context in React 16.3 and later: how it's created and who can read it.

easySign in to star problems

What Are the States of a Promise?

Frontend · Pending, then fulfilled or rejected — settled is final, and handlers always run later.

easySign in to star problems

What Were the Best Improvements in ES6?

Frontend · Pick two features and say which bug each one removed.

easySign in to star problems

Inheritance or Composition?

Frontend · "Is a" ties the child to the parent; "has a" combines small parts.

easySign in to star problems

What Is Endianness?

Frontend · The byte order of multi-byte values — and where JavaScript makes you care.

easySign in to star problems

What Do Object-Oriented Languages Share?

Frontend · Encapsulation, inheritance and polymorphism — and how JavaScript gets inheritance.

easySign in to star problems

Cookies, localStorage or sessionStorage?

Frontend · Size, lifetime and who can read it — HttpOnly cookies survive XSS.

easySign in to star problems

How Do You Secure a Site?

Frontend · HTTPS, CSP, cookie flags and escaping — each named with the attack it stops.

mediumSign in to star problems

Axios or fetch?

Frontend · fetch resolves on a 500; Axios rejects, parses JSON and intercepts.

easySign in to star problems

What Do You Think of GraphQL?

Frontend · One round trip and typed data, paid for in caching, query cost and N+1 resolvers.

mediumSign in to star problems

How Do You Build an npm Package?

Frontend · package.json fields, ESM builds with types, peer dependencies, and a dry-run before publishing.

easySign in to star problems

What Makes a Good Code Review?

Frontend · Correctness first, then readability and tests — small diffs, specific comments.

easySign in to star problems

How Would You Structure a Repo From Scratch?

Frontend · Group by feature, keep tests beside code, and wire checks into CI from the first commit.

easySign in to star problems

Have You Used Jest?

Frontend · Name what you test with it — including timers with fake timers.

easySign in to star problems

When Would You Use useMemo or useCallback?

Frontend · They cache a value and a function identity — and only matter when something compares them.

mediumSign in to star problems

preventDefault or stopPropagation?

Frontend · One cancels the browser's default action; the other stops the event traveling.

easySign in to star problems

Why <!DOCTYPE html>, and What Is Quirks Mode?

Frontend · The doctype selects standards mode; without it, browsers emulate 1990s layout.

easySign in to star problems

What Is a Compositing Layer?

Frontend · A GPU texture the compositor can move or fade without layout or paint.

mediumSign in to star problems

How Do You Make a Page Accessible?

Frontend · Native elements first, then names, keyboard, contrast, motion — and a real example.

mediumSign in to star problems

How Would You Implement Light and Dark Themes?

Frontend · Custom properties on the root, prefers-color-scheme by default, and no flash of the wrong theme.

easySign in to star problems

How Do You Adjust a Border or a Margin?

Frontend · Content, padding, border, margin — and what border-box changes about width.

easySign in to star problems

What Is an API?

Frontend · A contract for how one piece of software calls another.

easySign in to star problems

How Does the Browser Turn HTML Into Pixels?

Frontend · DOM, CSSOM, render tree, layout, paint, composite — six numbered steps.

mediumSign in to star problems

Repaint or Reflow?

Frontend · Which pipeline steps each kind of change re-runs — and how reads force layout.

mediumSign in to star problems

What Are FCP and LCP?

Frontend · First Contentful Paint and Largest Contentful Paint, with their good thresholds.

easySign in to star problems

How Would You Debug a Blank Page?

Frontend · Console, network, DOM, then bisect the deploys.

easySign in to star problems

How Would You Make a Site Faster?

Frontend · Measure first, then ship less, unblock rendering, cache, and move work.

mediumSign in to star problems

How Do You Deal With a Slow API?

Frontend · Show a shell at once, cache and parallelize, cancel stale requests — then fix the server.

easySign in to star problems

A Heavy Calculation Freezes the UI

Frontend · Move it to a Web Worker — or chunk it and yield when a worker isn't an option.

mediumSign in to star problems

Abortable Promise

Frontend · Promises can't be cancelled, so cancel the work — and reject once, with an AbortError, only while pending.

mediumSign in to star problems

Implement Throttle

Frontend · A leading call, then at most one call per window — with a trailing call that carries the latest arguments.

mediumSign in to star problems

Kanban Board

Frontend · Columns of cards with immutable moves: one pure moveCard function serves the buttons and the drag-and-drop alike.

mediumSign in to star problems

Grid Game: Lights Out

Frontend · State in one object, a pure toggle that flips a cell and its neighbours, one delegated click listener, and a render from state.

mediumSign in to star problems

Implement an Event Emitter

Frontend · A map from event name to listener list; copy the list before emitting so listeners can unsubscribe mid-emit.

mediumSign in to star problems

Implement deepEqual

Frontend · Primitives by value (NaN equals NaN), arrays by length and elements, plain objects by key set and values, recursively.

mediumSign in to star problems

Implement JSON.stringify

Frontend · A recursive serializer with the real rules: undefined vanishes from objects but becomes null in arrays, and strings need escaping.

mediumSign in to star problems

Undo/Redo Manager

Frontend · Two stacks: a new value pushes the old one onto undo and clears redo; undo and redo move values between them.

mediumSign in to star problems

Chessboard in React

Frontend · Derive the 64 squares in render — no board in state — then add selection and a move with one piece of state.

easySign in to star problems

Robot Eats Candies on a Grid

Frontend · Keyboard movement with walls and edges, a breadth-first path to the nearest candy walked by a requestAnimationFrame loop, and a debounced hint, in plain JavaScript or React.

mediumSign in to star problems

Grid Lights

Frontend · Remember the order cells were lit; when all are lit, a self-re-arming timeout switches them off in reverse.

mediumSign in to star problems

Memory Game

Frontend · A shuffled deck, at most two face-up ids, a set of matched faces, and one effect that resolves each pair.

mediumSign in to star problems

Whack-a-Mole

Frontend · Two intervals owned by one effect keyed on the running flag, and a round that ends when the clock hits zero.

mediumSign in to star problems

Selectable Cells

Frontend · Two corners in state and a derived rectangle; pointer events on cells plus one document listener for the release.

mediumSign in to star problems

Pixel Art

Frontend · A flat array of 225 colours, a palette, draw and erase modes, and a stroke that paints while the pointer is held.

mediumSign in to star problems

Nested Checkboxes

Frontend · Store only the leaves; every parent's checked and indeterminate state is derived from the leaves beneath it.

mediumSign in to star problems

Data Table I

Frontend · Three pieces of state — page, page size, sort — and rows derived from them in render.

mediumSign in to star problems

File Explorer

Frontend · A recursive component over nested data, with a set of expanded ids as the only state.

mediumSign in to star problems

useDebounce Hook

Frontend · A state copy of the value and one effect whose cleanup cancels the pending update on every change.

easySign in to star problems

Traffic Light

Frontend · One state value and one timeout per light, re-armed by an effect keyed on the colour; an interval can't do unequal durations.

easySign in to star problems

Data Table II

Frontend · Filters live in the column config and in one state object; rows are filtered, then sorted, then paged.

hardSign in to star problems

What Do You Check Before Calling a UI Component Done?

Frontend · The review you run on your own build: instances, state, HTML, forms, network, keyboard, edge cases, strings.

mediumSign in to star problems

Sign-Up Form

Frontend · Native attributes carry the rules, one message per field is linked by aria-describedby, and the button locks while the request is out.

mediumSign in to star problems

Like Button

Frontend · Three states the server confirms and one it hasn't: pending blocks a second click, failure shows its message, the label never changes.

mediumSign in to star problems

Windowed List

Frontend · One state value, scrollTop; a spacer as tall as the whole list; and only the rows under the viewport in the DOM, keyed by id.

mediumSign in to star problems

How Do You Approach a JavaScript Coding Question?

Frontend · Clarify the runtime and the edges, say which spec cases you are skipping, then dodge the one bug each classic is known for.

mediumSign in to star problems

Implement Function.prototype.bind

Frontend · A closure over thisArg and the leading arguments; the original runs later, with the call's own arguments appended.

easySign in to star problems

Implement classNames

Frontend · Strings and numbers pass through, objects add their truthy keys, arrays recurse, falsy values vanish, one space between.

easySign in to star problems

Implement Promise.allSettled

Frontend · Record every outcome by index as { status, value | reason }; it never rejects, and an empty input resolves at once.

mediumSign in to star problems

Implement Promise.any

Frontend · Resolve on the first fulfilment; reject only when every input has failed, with an AggregateError whose errors follow input order.

mediumSign in to star problems

Data Selection

Frontend · Merge per user with a Map re-inserted on every session so order follows the last one, then filter the merged rows.

hardSign in to star problems

Implement getElementsByTagName

Frontend · A depth-first walk over children comparing upper-cased tag names: document order for free, text nodes never seen.

mediumSign in to star problems

Retry With Exponential Backoff

Frontend · Try, wait, multiply the wait, try again: the first fulfilment wins, the last failure is the error, and no wait follows it.

mediumSign in to star problems

Unique Paths Grid Game

Frontend · A grid of obstacle toggles in a reducer, with the route count and one highlighted route derived from the grid rather than stored.

mediumSign in to star problems

TypeScript Kanban Board I

Frontend · Left and right arrows instead of drag-and-drop: one typed MOVE_TASK reducer action, and controls that disappear at the board's edges.

easySign in to star problems

TypeScript Kanban Board II

Frontend · Every moved task lands at the bottom of its new column: normalized state with one ordered ID list per status, then the board at 100,000 tasks.

mediumSign in to star problems

Movie List With Sort and Search

Frontend · Load a list from a fake endpoint with loading and error states, filter it by name as you type, and sort it by column with aria-sort; derive, do not store.

easySign in to star problems

Code Review: A Junior's React Change

Frontend · A working but fragile component to review out loud: what you flag first, how you say it so the author learns, what you would refactor, and what tests you ask for.

mediumSign in to star problems

Build a Comment Tree From Flat Records

Frontend · Turn a flat list of comments with parent ids into nested roots with children, in two passes with a map, without depending on input order or mutating the input.

easySign in to star problems

Nested Comment Thread

Frontend · A reusable comment component: replies nested to any depth, an inline reply form, a hide/show toggle with a count, and a flat list in state with the tree derived from it.

mediumSign in to star problems