Dom interview questions
Practice 88 questions on dom. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
88 questions
- EASY
Cookie Store
Implement get/set/remove over document.cookie, handling encoding and expiry.
15 minJavaScript - EASY
Copy to Clipboard Button
Build a button that copies text to the clipboard and shows a transient copied confirmation.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Counter
Build a counter component that increments a displayed number each time a button is clicked.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Deep Clone DOM
Implement a deep clone of a DOM node and its subtree (element, text, and attributes) without cloneNode.
15 minJavaScript - EASY
DOM Tree Height
Implement a function that returns the height (max depth) of a DOM element's subtree.
15 minJavaScript - EASY
Event Delegation
Implement a delegated event listener that matches events bubbling up from descendants against a selector.
15 minJavaScript - EASY
FAQ Disclosure
Build a list of FAQ questions that each expand to reveal an answer on click.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Generate CSS Selector
Implement a function that builds a unique CSS selector path from the root to a given element.
15 minJavaScript - EASY
Get DOM Tags
Implement a function returning the set of distinct tag names used in a DOM subtree, in document order.
15 minJavaScript - EASY
jQuery.css
Implement a jQuery-style helper that gets or sets inline CSS properties on a DOM element.
15 minJavaScript - EASY
Next Right Sibling
Implement a function that finds the element immediately to the right of a target at the same tree depth.
15 minJavaScript - EASY
Toast Notification
Build a toast that appears on trigger and auto-dismisses after a few seconds, with manual close.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Tooltip
Build a tooltip that shows on hover/focus of a trigger and hides on leave/blur.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Traverse DOM (BFS)
Implement a breadth-first traversal of a DOM tree, returning elements level by level.
15 minJavaScript - EASY
useClickAnywhere
Implement a hook that fires a callback whenever the user clicks anywhere in the window, cleaning up on unmount.
15 minJavaScript - EASY
useCopyToClipboard
Implement a hook returning the last copied text and an async copy function built on the Clipboard API.
15 minJavaScript - EASY
useDocumentTitle
Implement a hook that sets document.title and restores the previous title when the component unmounts.
15 minJavaScript - EASY
useFavicon
Implement a hook that swaps the page favicon imperatively to a given URL.
15 minJavaScript - EASY
useFocus
Implement a hook that exposes a ref plus a function to focus the attached element on demand.
15 minJavaScript - EASY
useHover
Implement a hook that reports whether a referenced element is currently being hovered.
15 minJavaScript - EASY
useWindowSize
Implement a hook that returns the current window width and height, updating on resize.
15 minJavaScript - MEDIUM
Autoplay Carousel
Build an image carousel that auto-advances on a timer, pauses on hover, and has manual controls.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Corresponding Node Across Pages
Implement a function that locates the node in a mirrored DOM tree occupying the same path as a given node.
25 minJavaScript - MEDIUM
CSS Selector Matches
Implement Element.matches: test whether an element satisfies a compound CSS selector (tag, id, class, attribute).
25 minJavaScript - MEDIUM
DOM Method Chaining
PREMIUMBuild a jQuery-style wrapper whose methods return this so calls like addClass().text() chain.
25 minJavaScript - MEDIUM
Finite State Machine
PREMIUMImplement a state machine from a config of states and transitions, with send, guards, and entry actions.
25 minJavaScript - MEDIUM
Form Serialize
PREMIUMSerialize a form's fields into a nested object, handling checkboxes, multi-selects, and bracket names.
25 minJavaScript - MEDIUM
getElementsByClassName
Implement a function that returns all DOM elements containing every one of the specified class names.
25 minJavaScript - MEDIUM
getElementsByStyle
Implement a function that returns all DOM elements whose computed style matches a given property and value.
25 minJavaScript - MEDIUM
getElementsByTagName
Implement a function that walks a DOM tree and returns every descendant element matching a given tag name.
25 minJavaScript - MEDIUM
Hash Router
PREMIUMBuild a client-side router over location.hash with route params and a change subscription.
25 minJavaScript - MEDIUM
Heatmap Calendar
Build a contribution-style heatmap calendar that colors each day cell by its activity value.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
History Router
PREMIUMBuild a client-side router over the History API (pushState/popstate) with path params.
25 minJavaScript - MEDIUM
HTML Sanitizer
Implement a simplified HTML sanitizer that strips out unsafe tags and attributes from a given DOM tree.
25 minJavaScript - MEDIUM
Identical DOM Trees
Implement a function that recursively compares two DOM trees and returns whether they are structurally equal.
25 minJavaScript - MEDIUM
IntersectionObserver Polyfill
Implement a scroll/resize-driven fallback that reports when observed elements enter the viewport.
25 minJavaScript - MEDIUM
jQuery Class Manipulation
Implement chainable addClass, removeClass, toggleClass, and hasClass helpers on a DOM element wrapper.
25 minJavaScript - MEDIUM
JSON Path Query
PREMIUMResolve a dotted path with array indices and a wildcard against a nested object, returning matches.
25 minJavaScript - MEDIUM
JSX Runtime
PREMIUMImplement the jsx() factory (type, props, children) that a JSX transform compiles to.
25 minJavaScript - MEDIUM
Lazy Load Images
PREMIUMSwap each image's data-src into src as it nears the viewport, using an IntersectionObserver.
25 minJavaScript - MEDIUM
LRU Cache
PREMIUMImplement a fixed-capacity least-recently-used cache with O(1) get and put via a map plus a linked list.
25 minJavaScript - MEDIUM
Markdown Parser
PREMIUMParse a subset of Markdown (headings, bold, italics, links, code) into an HTML string.
25 minJavaScript - MEDIUM
Mini Template Engine
PREMIUMImplement a string template engine with {{ variable }} interpolation and nested-path lookup.
25 minJavaScript - MEDIUM
Mutation Observer Mini
Build a mini MutationObserver that diffs a subtree on demand and reports added and removed nodes.
25 minJavaScript - MEDIUM
Node Registry
Implement a registry that associates values with DOM nodes without leaking memory once nodes are gone.
25 minJavaScript - MEDIUM
Notification Center
Build a notification center with an unread badge, mark-as-read, and dismiss.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Observable Store
Build a tiny state store with getState, setState, and subscribe that notifies listeners on change.
25 minJavaScript - MEDIUM
OTP Input
Build a one-time-code input of separate boxes with auto-advance, backspace, and paste handling.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Pixel Art
Build a pixel art editor where you pick a color from a palette and paint individual cells on a grid canvas.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
PubSub with Wildcards
Implement an event bus whose subscriptions support wildcard segments matching any single topic level.
25 minJavaScript - MEDIUM
Query Selector All
Implement querySelectorAll for descendant-combinator selectors, returning matches in document order.
25 minJavaScript - MEDIUM
Resize Observer Mini
Build a polling-based ResizeObserver that reports elements whose content-box size has changed.
25 minJavaScript - MEDIUM
Tagged Template HTML
PREMIUMImplement an html tagged-template function that interpolates values safely into a DOM fragment.
25 minJavaScript - MEDIUM
Two-Way Binding
Wire an input and a model object so edits to either side stay in sync via events and a setter.
25 minJavaScript - MEDIUM
useBreakpoint
Implement a hook that returns the active responsive breakpoint name derived from the current window width.
25 minJavaScript - MEDIUM
useClickOutside
Implement a hook that fires a callback when a pointer event lands outside a referenced element.
25 minJavaScript - MEDIUM
useEventListener
Implement a hook that attaches and cleans up a browser event listener on a target element or window.
25 minJavaScript - MEDIUM
useGeolocation
Implement a hook wrapping the Geolocation API to expose position, error, and loading state.
25 minJavaScript - MEDIUM
useIntersectionObserver
Implement a hook that reports whether a ref'd element is intersecting the viewport via IntersectionObserver.
25 minJavaScript - MEDIUM
useLongPress
Implement a hook that fires a callback after a pointer is held down past a delay, cancelling on early release or move.
25 minJavaScript - MEDIUM
useMediaQuery
Implement a hook that returns whether a media query currently matches and updates on changes.
25 minJavaScript - MEDIUM
useNetworkState
Implement a hook that reports online/offline status and connection info from the Network Information API.
25 minJavaScript - MEDIUM
useScript
Implement a hook that injects an external script tag and reports its loading status, deduping repeated sources.
25 minJavaScript - MEDIUM
useScrollPosition
Implement a hook that tracks the window scroll x/y position with a passive listener, throttled with rAF.
25 minJavaScript - MEDIUM
Virtual DOM Diff
PREMIUMImplement a diff that patches real DOM from an old vnode tree to a new one, minimizing changes.
25 minJavaScript - MEDIUM
Virtual DOM: createElement + render
PREMIUMImplement createElement to build a virtual DOM tree and render to turn it into real DOM nodes.
25 minJavaScript - HARD
Async Event Emitter
PREMIUMBuild an emitter whose emit awaits async listeners, with once, off, and serial or parallel dispatch.
40 minJavaScript - HARD
Drag & Drop Sortable
PREMIUMReorder a list by pointer drag, computing the target index from the cursor over item midpoints.
40 minJavaScript - HARD
Gantt Chart
PREMIUMBuild a Gantt chart that renders tasks as bars positioned across a timeline by start and duration.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
getElementsByTagNameHierarchy
PREMIUMImplement a function that finds all DOM elements matching an ancestor-to-descendant tag-name hierarchy.
40 minJavaScript - HARD
HTML Tokenizer & Parser
PREMIUMTokenize an HTML string and build a nested node tree, handling attributes, void, and nested tags.
40 minJavaScript - HARD
Idle Task Scheduler
PREMIUMRun a queue of tasks in time-sliced batches, yielding between slices to keep the frame responsive.
40 minJavaScript - HARD
Image Cropper
PREMIUMBuild an image cropper with a draggable, resizable crop region over an image.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Keyed DOM Reconcile
PREMIUMReconcile two keyed child lists into a minimal set of DOM inserts, moves, and removals.
40 minJavaScript - HARD
Lowest Hiding Element
PREMIUMImplement a function that finds the deepest common ancestor whose hiding would conceal every target element.
40 minJavaScript - HARD
Reactive Proxy Signals
PREMIUMBuild reactive state with a Proxy that tracks reads and re-runs registered effects on write.
40 minJavaScript - HARD
Rich Text Editor
PREMIUMBuild a contenteditable rich-text editor with bold/italic/list formatting and a live toolbar state.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Selectable Cells
PREMIUMBuild a grid where you click and drag across cells to select a rectangular range of them.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Spreadsheet Grid
PREMIUMBuild a grid of cells with formula evaluation and dependent-cell recalculation.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Table of Contents
PREMIUMImplement a function that walks an HTML document's headings and builds a nested table of contents.
40 minJavaScript - HARD
Text Between Nodes
PREMIUMImplement a function that gathers the text content lying between two DOM nodes in document order.
40 minJavaScript - HARD
Tooltip Positioning Engine
PREMIUMCompute a tooltip's position around an anchor, flipping and shifting to stay inside the viewport.
40 minJavaScript - HARD
useDraggable
PREMIUMImplement a pointer-based drag hook that tracks an element's x/y offset with start/move/end handlers.
40 minJavaScript - HARD
useInfiniteScroll
PREMIUMImplement a hook that loads more pages when a sentinel element scrolls into view, guarding against duplicate loads.
40 minJavaScript - HARD
useResizeObserver
PREMIUMImplement a hook that reports a ref'd element's content-box size via ResizeObserver.
40 minJavaScript - HARD
useVirtualList
PREMIUMImplement a windowing hook that renders only the visible rows of a long list, with correct spacer offsets.
40 minJavaScript - HARD
Virtual Scroll List
PREMIUMCompute the visible slice and spacer offsets to render only on-screen rows of a huge list.
40 minJavaScript - HARD
Virtualized List
PREMIUMBuild a windowed list that renders only the visible rows of a large dataset for smooth scrolling.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue