Easy frontend interview questions
152 questions at easy difficulty. Build the muscle for real frontend interviews with a runnable editor and explained solutions.
152 questions
- EASY
Accordion
Build an accordion component with stacked sections whose content panels expand and collapse on click.
20 minUI / FrameworksGoogle · Amazon · MetaAngularReactHTML / CSS / JSVue - EASY
Array findLast / findLastIndex
Implement findLast and findLastIndex — scan an array from the end for the last element matching a predicate.
15 minJavaScript - EASY
Array XOR (Symmetric Difference)
Implement lodash xor — return the values that appear in exactly one of the given arrays, with duplicates removed.
20 minJavaScript - EASY
Array.prototype.at
Implement Array.prototype.myAt — return the element at a given index, supporting negative offsets from the end.
15 minJavaScript - EASY
Array.prototype.every
Implement Array.prototype.every — return false as soon as an element fails the predicate, true when empty.
15 minJavaScript - EASY
Array.prototype.filter
Implement Array.prototype.filter from scratch as a method on the array prototype.
15 minJavaScript - EASY
Array.prototype.flat
Implement Array.prototype.flat — flatten nested arrays to a given depth (default 1, Infinity for all levels), dropping holes.
15 minJavaScript - EASY
Array.prototype.forEach
Implement Array.prototype.forEach — run a callback on each element as (value, index, array), skipping sparse holes.
15 minJavaScript - EASY
Array.prototype.includes
Implement Array.prototype.includes — test membership with SameValueZero so NaN matches, honoring negative fromIndex.
15 minJavaScript - EASY
Array.prototype.indexOf
Implement Array.prototype.indexOf — first index of a value by strict equality, supporting a negative fromIndex.
15 minJavaScript - EASY
Array.prototype.some
Implement Array.prototype.some — return true as soon as any element passes the predicate, false when empty.
15 minJavaScript - EASY
Array.prototype.square
Implement a custom Array.prototype.square method that returns a new array with each value squared.
15 minJavaScript - EASY
Async CountDown Latch
Implement a countdown latch whose wait resolves once countDown has been called the required number of times.
15 minJavaScript - EASY
Avatar Group
Build a row of overlapping avatars that collapses the overflow into a plus-N badge.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Balanced Brackets
Implement a function that checks whether a string of brackets is properly opened and closed in order.
15 minAlgorithms - EASY
Basic Autocomplete
Build an autocomplete input that filters a static list and lets you pick a suggestion.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Binary Tree Equal
Implement a function that returns whether two binary trees have identical structure and node values.
15 minAlgorithms - EASY
Binary Tree Maximum Depth
Implement a function that returns the maximum depth from root to leaf in a binary tree.
15 minAlgorithms - EASY
Bit Reversal
Implement a function that reverses the order of the bits in the binary representation of a number.
15 minAlgorithms - EASY
Breadcrumbs
Build a breadcrumb trail from a path array, separating crumbs and marking the current page.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Bubble Sort
Implement bubble sort, repeatedly swapping adjacent out-of-order pairs until the array is sorted.
15 minAlgorithms - 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
Character Counter Textarea
Build a textarea with a live character counter that warns as it nears a maximum length.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Chunk
Implement a function that splits an array into groups of a given size, with the last group holding the remainder.
15 minJavaScript - EASY
Clamp
Implement a function that constrains a number to lie within an inclusive minimum and maximum range.
15 minJavaScript - EASY
Color Swatch Picker
Build a swatch color picker where clicking a swatch selects it and previews the chosen color.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Combine Two Sorted Linked Lists
Implement a function that merges two sorted linked lists into a single sorted linked list.
15 minAlgorithms - EASY
Compact
Implement a function that returns a new array with every falsy value stripped out.
15 minJavaScript - EASY
Compose
Implement a function that composes functions right-to-left so the output of each feeds into the next.
15 minJavaScript - EASY
Contact Form
Build a contact form that posts the user's name, email, and message to a backend endpoint.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - 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
Count Set Bits in a Binary Number
Implement a function that counts the number of 1 bits in the binary representation of an integer.
15 minAlgorithms - 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
Counter
Build a counter component that increments a displayed number each time a button is clicked.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Cursor Pagination Fetcher
Fetch successive pages with an opaque cursor, accumulating items and tracking whether more remain.
15 minJavaScript - EASY
Cycle
Implement a function that, given several values, returns a function that yields each one in turn and loops forever.
15 minJavaScript - EASY
Data Merging
Implement a function that consolidates rows sharing the same user into a single grouped record.
15 minJavaScript - EASY
Debounce
Implement a function that delays invoking another function until a specified period of inactivity has passed.
15 minJavaScriptGoogle · Amazon · Meta - EASY
Deep Clone DOM
Implement a deep clone of a DOM node and its subtree (element, text, and attributes) without cloneNode.
15 minJavaScript - EASY
Difference
Implement a function that returns the elements from the first array that do not appear in the second.
15 minJavaScript - EASY
DOM Tree Height
Implement a function that returns the height (max depth) of a DOM element's subtree.
15 minJavaScript - EASY
Drop Right While
Implement a function that drops trailing array elements as long as a predicate keeps returning truthy.
15 minJavaScript - EASY
Drop While
Implement a function that drops leading array elements as long as a predicate keeps returning truthy.
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
Fill
Implement a function that replaces array elements with a given value between an optional start and end index.
15 minJavaScript - EASY
Find Duplicates in Array
Implement a function that checks whether an array contains any duplicate numbers.
15 minAlgorithms - EASY
Find Index
Implement a function that returns the index of the first array element matching a predicate, or -1 if none match.
15 minJavaScript - EASY
Find Last Index
Implement a function that returns the index of the last array element matching a predicate, or -1 if none match.
15 minJavaScript - EASY
Find Missing Number in Sequence
Implement a function that returns the single missing number from a sorted sequence of integers.
15 minAlgorithms - EASY
First Bad Version
Find the first failing version among 1..n where a monotonic isBad check flips from false to true — a boundary binary search using the fewest checks.
15 minAlgorithms - EASY
Flight Booker
Build a small form that books either a one-way or return flight, with validation tying the two date fields together.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Flip Binary Tree
Implement a function that mirrors a binary tree by swapping the left and right children of every node.
15 minAlgorithms - EASY
From Pairs
Implement a function that builds an object from an array of [key, value] pair tuples.
15 minJavaScript - EASY
Function Length
Implement a function that returns the number of declared parameters of a given function.
15 minJavaScript - EASY
Generate CSS Selector
Implement a function that builds a unique CSS selector path from the root to a given element.
15 minJavaScript - EASY
Generate Table
Build a component that renders a table of sequential numbers given a row count and a column count.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - 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
Holy Grail
Build the classic holy grail page layout with a header, footer, and three columns of content.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
In Range
Implement a function that checks whether a number lies within a half-open range, swapping bounds when needed.
15 minJavaScript - EASY
Insertion Sort
Implement insertion sort by building the sorted portion one element at a time from the input.
15 minAlgorithms - EASY
Intersection
Implement a function that returns the unique values present in every input array.
15 minJavaScript - EASY
jQuery.css
Implement a jQuery-style helper that gets or sets inline CSS properties on a DOM element.
15 minJavaScript - EASY
Key By
Implement lodash keyBy — index a collection into an object keyed by an iteratee's return, keeping the last item for each key.
15 minJavaScript - EASY
Like Button
Build a Like button that toggles between liked and unliked states with matching visual feedback.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Linked List Reversal
Implement a function that reverses a singly linked list in place and returns the new head.
15 minAlgorithms - EASY
List Format
Implement a function that joins an array of strings into a grammatical list with commas and a conjunction.
15 minJavaScript - EASY
Make Counter
Implement a factory that takes a starting integer and returns a function that returns the next value on each call.
15 minJavaScript - EASY
Map.groupBy
Implement Map.groupBy — group an iterable into a Map whose keys can be any value, preserving key insertion order.
15 minJavaScript - EASY
Max By
Implement a function that returns the array element producing the largest value when run through an iteratee.
15 minJavaScript - EASY
Mean
Implement a function that computes the arithmetic mean of the numbers in an array.
15 minJavaScript - EASY
Meeting Calendar
Implement a function that determines whether a person can attend every meeting given their time intervals.
15 minAlgorithms - EASY
Min By
Implement a function that returns the array element producing the smallest value when run through an iteratee.
15 minJavaScript - EASY
Modal Dialog
Build a reusable modal dialog component that you can open from a trigger and close with a button.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Mortgage Calculator
Build a calculator that computes the monthly payment for a loan based on principal, rate, and term inputs.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Move Zeroes
Move all zeroes to the end of an array in place while keeping the non-zero elements in their original order.
20 minAlgorithmsMeta · Google - 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
nth
Implement nth — return the element at index n, counting from the end when n is negative, so head is nth(0) and last is nth(-1).
15 minJavaScript - EASY
Number of Arguments
Implement a function that returns the count of arguments passed to it at call time.
15 minJavaScript - EASY
Object Map
Implement a function that returns a new object with every value transformed by a mapper callback.
15 minJavaScript - EASY
Object.entries
Implement Object.entries — return an object's own enumerable string-keyed [key, value] pairs in insertion order.
15 minJavaScript - EASY
Object.fromEntries
Implement Object.fromEntries — build an object from any iterable of [key, value] pairs, with later keys winning.
15 minJavaScript - EASY
Object.is
Implement Object.is — same-value equality that treats NaN as equal to itself and keeps +0 distinct from -0.
15 minJavaScript - EASY
Once
Implement a function that wraps a callback so it runs at most one time and reuses that result thereafter.
15 minJavaScript - EASY
Optimal Stock Trading
Implement a function that computes the maximum profit obtainable from one buy and one sell of a stock.
15 minAlgorithms - EASY
Pagination UI
Build pagination controls with previous/next and numbered pages that report the current page.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Pair Sum
Implement a function that finds two numbers in an array that add up to a given target.
15 minAlgorithms - EASY
Password Strength Meter
Build a password field with a live strength meter that scores the input as you type.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Progress Bar
Build a progress bar component that visualizes the percentage completion of an operation.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Progress Bars
Build a component that renders a list of progress bars which animate from empty to full as they mount.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - 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
Queue
Build a queue data structure supporting enqueue, dequeue, peek, and size in FIFO order.
15 minAlgorithms - EASY
Range
Implement a function that builds an array of numbers from start up to end, stepping by a given increment.
15 minJavaScript - EASY
Range Right
Implement a function that builds an array of numbers from end down to start in descending order.
15 minJavaScript - EASY
Roman to Integer
Convert a Roman numeral string to its integer value, handling subtractive pairs like IV and IX.
15 minAlgorithmsAmazon · Microsoft · Adobe - EASY
Segmented Control
Build a segmented control where clicking a segment selects it and highlights the active option.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Selection Sort
Implement selection sort to order an array by repeatedly picking the smallest remaining element.
15 minAlgorithms - EASY
Size
Implement a function that returns the element count of any collection — array, string, object, Map, or Set.
15 minJavaScript - 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
Stack
Build a stack data structure that supports the standard push, pop, peek, and size operations.
15 minAlgorithms - EASY
Staircase Climbing Combinations
Implement a function that counts the distinct ways to climb to the top of a staircase taking one or two steps.
15 minAlgorithms - EASY
String Anagram
Implement a function that determines whether two strings are anagrams of each other.
15 minAlgorithms - EASY
String Palindrome
Implement a function that returns whether a string reads the same forwards and backwards.
15 minAlgorithms - EASY
String.prototype.padStart
Implement String.prototype.padStart — pad a string to a target length on the left, truncating a multi-char pad.
15 minJavaScript - EASY
String.prototype.repeat
Implement String.prototype.repeat — join a string n times, throwing RangeError on a negative or infinite count.
15 minJavaScript - EASY
String.prototype.trim
Implement String.prototype.trim — strip leading and trailing whitespace, including Unicode whitespace, from a string.
15 minJavaScript - EASY
Sum By / Mean By
Implement lodash sumBy and meanBy — total and average an array by an iteratee that maps each element to a number.
15 minJavaScript - EASY
takeWhile
Implement take and takeWhile — grab the leading n elements, or the leading run that satisfies a predicate.
15 minJavaScript - EASY
Temperature Converter
Build a widget that converts between Celsius and Fahrenheit, updating either field as the other changes.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Text Search
Implement a function that wraps occurrences of a search term within a string in highlight markup.
15 minJavaScript - EASY
times
Implement times — invoke a function n times and collect the results into an array.
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
Toggle Switch
Build an on/off toggle switch that flips state on click and slides its knob to reflect it.
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
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
Traverse DOM (BFS)
Implement a breadth-first traversal of a DOM tree, returning elements level by level.
15 minJavaScript - EASY
Tweet
Build a static tweet component that mirrors the layout of a single post on Twitter.
15 minUI / FrameworksAngularReactHTML / CSS / JSVue - EASY
Type Utilities
Implement a set of helper functions that report the primitive type of any JavaScript value.
15 minJavaScript - 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 - EASY
Unique Array
Implement a function that returns a new array with duplicate values removed while preserving original order.
15 minJavaScript - EASY
useBoolean
Implement a hook that exposes a boolean value alongside setTrue, setFalse, and toggle helpers.
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
useCounter
Implement a hook that exposes a numeric count along with increment, decrement, and reset helpers.
15 minJavaScript - EASY
useCounter II
Rewrite useCounter so the returned helpers keep stable identities across renders.
15 minJavaScript - EASY
useCycle
Implement a hook that returns the current value of a sequence and advances to the next on demand.
15 minJavaScript - EASY
useCycleList
Implement a hook that steps through an array with wraparound, exposing the current item and next/prev/set.
15 minJavaScript - EASY
useDefault
Implement a hook that falls back to a default value whenever the underlying state becomes null or undefined.
15 minJavaScript - EASY
useDocumentTitle
Implement a hook that sets document.title and restores the previous title when the component unmounts.
15 minJavaScript - EASY
useEffectOnce
Implement a hook that runs the given effect a single time after mount, regardless of subsequent renders.
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
useIsFirstRender
Implement a hook that returns true only on the first render and false on every render after.
15 minJavaScript - EASY
useIsMounted
Implement a hook returning a function that reports whether the component is still mounted, to guard async setState.
15 minJavaScript - EASY
useLatest
Implement a hook that returns a ref always holding the newest value, so callbacks and effects can read it without going stale.
15 minJavaScript - EASY
useLocalStorage
Implement a useState-like hook that persists to localStorage, with SSR-safe init and cross-tab sync.
15 minJavaScript - EASY
useObject
Implement a hook that holds an object in state and exposes helpers to merge updates or reset its value.
15 minJavaScript - EASY
usePrevious
Implement a hook that remembers and returns the value a state held on the previous render.
15 minJavaScript - EASY
useRenderCount
Implement a hook that counts how many times a component has rendered, without causing extra renders.
15 minJavaScript - EASY
useSessionStorage
Implement a useState-like hook backed by sessionStorage, with a graceful fallback when it is unavailable.
15 minJavaScript - EASY
useSet
Implement a hook that stores a Set in state and exposes add, delete, has, and clear helpers.
15 minJavaScript - EASY
useStateWithReset
Implement a useState-like hook that also returns a reset function which restores the initial value.
15 minJavaScript - EASY
useToggle
Implement a hook that holds a boolean and returns a stable toggle function to flip its value.
15 minJavaScript - EASY
useUpdateEffect
Implement a useEffect variant that skips the first render and fires only on subsequent updates.
15 minJavaScript - EASY
useWindowSize
Implement a hook that returns the current window width and height, updating on resize.
15 minJavaScript - EASY
without
Implement without — return a copy of an array with the given values excluded, matched by SameValueZero.
15 minJavaScript