Timers interview questions
Practice 39 questions on timers. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
39 questions
- EASY
Cancellable Interval
Implement a setInterval wrapper that returns a function which stops the interval when invoked.
15 minJavaScript - EASY
Cancellable Timeout
Implement a setTimeout wrapper that returns a function you can call to cancel the pending callback.
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
Countdown Timer
Build a countdown timer that ticks down from a start time and can start, pause, and reset.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Debounce
Implement a function that delays invoking another function until a specified period of inactivity has passed.
15 minJavaScriptGoogle · Amazon · Meta - EASY
Sleep
Implement a function that returns a promise resolving after the specified number of milliseconds.
15 minJavaScript - EASY
Sliding TTL Cache
Implement a cache whose entries expire a fixed time after their last access, not after being set.
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
Traffic Light
Build a traffic light that cycles green to yellow to red on a timer and loops indefinitely.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Typewriter Pacer
Buffer bursty streamed text and emit it one character at a time at a steady cadence, with flush and stop controls.
18 minJavaScript - MEDIUM
Analog Clock
Build an analog clock whose hour, minute, and second hands move smoothly to reflect the current time.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Analytics Event SDK
PREMIUMBuild an analytics client that queues tracked events, flushes them in batches, and retries failed sends with backoff.
25 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 Memoize with TTL
Implement an async memoize that caches results by key for a TTL and coalesces concurrent calls for the same key.
25 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
Batch Event Flusher
Buffer events and flush them in batches when a size threshold or a max-wait timer is reached.
25 minJavaScript - MEDIUM
Debounce II
PREMIUMExtend debounce with cancel and flush methods to abort or immediately invoke pending calls.
25 minJavaScript - MEDIUM
Debounce III
PREMIUMExtend debounce with a maxWait option that forces a call after a maximum delay even under constant activity.
25 minJavaScript - MEDIUM
Digital Clock
Build a 7-segment style digital clock that updates to display the current time.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Grid Lights
Build a grid of cells that light up on click and then deactivate one by one in the reverse order they were activated.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Memory Game
Build a memory card-matching game where players flip cards to find matching pairs.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Progress Bars II
Build a list of progress bars that fill in sequence, each one starting only after the previous bar finishes.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - 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
Resilient Fetch Wrapper
Wrap an async call with retries, backoff, and a per-attempt timeout so transient failures recover.
25 minJavaScript - MEDIUM
Resumable Interval
Implement an interval helper that exposes start, pause, and resume controls while preserving elapsed progress.
25 minJavaScript - MEDIUM
Snake Game
PREMIUMBuild the classic snake game on a grid with keyboard control, growth on eating, and game over.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Stale-While-Revalidate Cache
PREMIUMReturn cached data instantly, serving stale values while revalidating them in the background.
25 minJavaScript - MEDIUM
Stopwatch
Build a stopwatch widget that measures elapsed time with start, stop, and reset controls.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - MEDIUM
Throttle
Implement a function that limits how often a wrapped function can be invoked within a time window.
15 minJavaScriptGoogle · Amazon · Meta - MEDIUM
Throttle II
PREMIUMExtend throttle with cancel and flush methods plus leading and trailing edge options.
25 minJavaScript - MEDIUM
useCountdown
Implement a hook that drives a countdown timer with start, pause, and reset controls.
25 minJavaScript - MEDIUM
useDebounce
PREMIUMImplement a hook that returns a debounced version of a value, updating only after a quiet period.
25 minJavaScript - MEDIUM
useIdle
Implement a hook that flags the user as idle after a period without keyboard, pointer, or scroll activity.
25 minJavaScript - MEDIUM
useInterval
Implement a hook that runs a callback on a timer with a configurable, pauseable delay.
25 minJavaScript - MEDIUM
useTimeout
Implement a hook that runs a callback after a given delay and cleans up when the component unmounts.
25 minJavaScript - MEDIUM
Whack-A-Mole
Build the arcade game where moles randomly appear in a grid and players click them to score.
25 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Cooperative Scheduler
Run a queue of tasks in time slices, yielding control between them so the main thread stays responsive.
40 minJavaScript - HARD
Progress Bars IV
PREMIUMBuild progress bars that fill concurrently up to three at a time, and let the user pause and resume each one.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue - HARD
Tetris
PREMIUMBuild Tetris with falling tetrominoes, rotation, line clears, and scoring.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue