JavaScriptReactAngularVueSvelteCSSHTMLTypeScript

JavaScript Interview Questions

440+ most important JavaScript interview questions, from library APIs and utility functions to algorithms and UI components.
Solved by ex-interviewers
Test cases
Code in browser

Questions List

JavaScript Interview GuidesExplore our starter guides to get a solid grasp of JavaScript interview prep before jumping into practice.
0/5 guides
GUIDES
  • CounterWarm up questionBuild a simple counter that increments whenever a button is clicked
    Available frameworks
  • Make CounterImplement a function that accepts an integer value and returns a function that can be repeatedly called to return increasing values
    Languages
  • MeanImplement a function that finds the mean of the values inside an array
    Languages
  • Function.prototype.callImplement the Function.prototype.call() function that calls the function with a given `this` value and provided arguments
    Languages
  • Min ByImplement a function that finds the minimum element based on the specified criteria
    Languages
  • Selection SortImplement a function that performs a selection sort
    Languages
  • StackImplement a stack data structure containing the common stack methods
    Languages
  • Type UtilitiesImplement utilities to determine primitive variable types in JavaScript
    Languages
  • AccordionBuild an accordion component that a displays a list of vertically stacked sections with each containing a title and content snippet
    Available frameworks
  • Array.prototype.reduceImplement the Array.prototype.reduce() method
    Languages
  • Count Set Bits in a Binary NumberImplement a function to find set bits in binary representation of a given integer
    Languages
  • CycleImplement a function that takes one or more values and returns a function that cycles through those values each time it is called
    Languages
  • Find Duplicates in ArrayImplement a function to check if there are any duplicate numbers in the array
    Languages
  • Find Missing Number in SequenceImplement a function to find the missing element in a sorted array
    Languages
  • Insertion SortImplement a function that performs an insertion sort
    Languages
  • Optimal Stock TradingImplement a function to find the maximum profit achievable by buying and selling a stock once
    Languages
  • Pair sumImplement a function to find two numbers within an array of integers that add up to a target integer
    Languages
  • Progress BarsBuild a list of progress bars that fill up gradually when they are added to the page
    Available frameworks
  • String AnagramImplement a function to determine if two strings are anagram of each other
    Languages
  • Type Utilities IIImplement utilities to determine non-primitive variable types in JavaScript
    Languages
  • Binary Tree Maximum DepthImplement a function to find the maximum depth of a binary tree
    Languages
  • Flip Binary TreeImplement a function to flip the nodes in a binary tree
    Languages
  • Mortgage CalculatorBuild a calculator that computes the monthly mortgage for a loan
    Available frameworks
  • Staircase Climbing CombinationsImplement a function to find the number of ways to reach at the top of staircase
    Languages
  • Balanced BracketsImplement a function to determine if a string contains balanced brackets
    Languages
  • Binary Tree EqualImplement a function to determine whether two binary trees are equal
    Languages
  • Bit CountingImplement a function to find number of set bits from 0 to n
    Languages
  • Bit ReversalImplement a function to flip the order of the bits in a given number
    Languages
  • Linked List ReversalImplement a function to reverse a linked list
    Languages
  • String PalindromeImplement a function to determine if a string is a palindrome
    Languages
  • Linked List Detect CycleImplement a function to detect if there are cycles in a linked list
    Languages
  • Binary Tree SubtreeImplement a function to check if a binary tree is a subtree of another binary tree
    Languages
  • Linked Lists Combine Two SortedImplement a function to combine two sorted linked list
    Languages
  • Meeting CalendarImplement a function to check if all meetings can be attended
    Languages
  • Array Product Excluding CurrentImplement a function to find the product of elements in an array excluding the current element
    Languages
  • Binary SearchImplement a function that performs binary search on an array of numbers
    Languages
  • Breadth-first SearchImplement a breadth-first search algorithm that traverses a directed graph in a breadth-first manner
    Languages
  • Count ByImplement a function that counts the number of times a value appears in an array based on a function or property name
    Languages
  • CurryImplement a function that transforms a function that takes multiple arguments into a function that can be repeatedly called with only one argument at a time
    Languages
  • DebounceImplement a function to limit how many times a function can be executed by delaying the execution of the function until after a specified time after its last execution attempt
    Languages
  • Depth-first SearchImplement a depth-first search algorithm that traverses a directed graph in a depth-first manner
    Languages
  • Heap SortImplement a function that performs a heap sort
    Languages
  • Is the Graph a TreeImplement a function to determine if a graph is a valid tree
    Languages
  • Maximum Water Trapped Between WallsImplement a function to find the maximum water volume between two walls in an array of walls
    Languages
  • PromisifyImplement a function that takes a function following the common error-first callback style and returns a version that returns promises
    Languages
  • QueueImplement a queue data structure containing the common queue methods
    Languages
  • TabsBuild a tabs component that displays a list of tab elements and one associated panel of content at a time
    Available frameworks
  • ThrottleImplement a function to control the execution of a function by limiting how many times it can execute over time
    Languages
  • ClassnamesImplement a function that conditionally joins CSS class names together
    Languages
  • Data MergingImplement a function to merge rows of data from the same user
    Languages
  • Data TableBuild a users data table with pagination features
    Available frameworks
  • Dice RollerBuild a dice roller app that simulates the results of rolling 6-sided dice
    Available frameworks
  • Event EmitterImplement a class that can subscribe to and emit events that trigger attached callback functions
    Languages
  • File ExplorerBuild a file explorer component to navigate files and directories in a tree-like hierarchical viewer
    Available frameworks
  • FlattenImplement a function that recursively flattens an array into a single level deep
    Languages
  • getElementsByStyleImplement a function to get all DOM elements that are rendered using the specified style
    Languages
  • HTML SerializerImplement a function to serialize an object into an HTML string with indentation
    Languages
  • JSON.stringifyImplement a function that converts a JavaScript value into a JSON string
    Languages
  • Like ButtonBuild a Like button that changes appearance based on the states
    Available frameworks
  • List FormatImplement a function that formats a list of items into a single readable string
    Languages
  • MemoizeImplement a function that returns a memoized version of a function which accepts a single argument
    Languages
  • Merge SortImplement a function that performs a recursive merge sort
    Languages
  • Modal DialogBuild a reusable modal dialog component that can be opened and closed
    Available frameworks
  • Promise.allImplement the Promise.all() function that resolves to an array of results if all the input elements are resolved or rejects otherwise
    Languages
  • Promise.anyImplement the Promise.any() function that resolves when any of the input elements are resolved
    Languages
  • Quick SortImplement a function that performs a recursive quick sort
    Languages
  • Squash ObjectImplement a function that returns a new object after squashing the input object into a single level of depth
    Languages
  • Star RatingBuild a star rating component that shows a row of star icons for users to select the number of filled stars corresponding to the rating
    Available frameworks
  • Todo ListBuild a Todo list that lets users add new tasks and delete existing tasks
    Available frameworks
  • Topological SortImplement a function that performs a topological sort
    Languages
  • Traffic LightBuild a traffic light where the lights switch from green to yellow to red after predetermined intervals and loop indefinitely
    Available frameworks
  • Binary Tree Level Order TraversalImplement a function to find the level order traversal of a binary tree
    Languages
  • Deep CloneImplement a function that performs a deep copy of a value
    Languages
  • Deep EqualImplement a function that determines if two values are equal
    Languages
  • Digital ClockBuild a 7-segment digital clock that shows the current time
    Available frameworks
  • getElementsByClassNameImplement a function to get all DOM elements that contain the specified classes
    Languages
  • Map Async LimitImplement a function that maps an array of items with an asynchronous mapping function while not exceeding the concurrency limit
    Languages
  • Maximum Sum in Contiguous ArrayImplement a function to find the subarray with the maximum sum
    Languages
  • Smallest element in rotated sorted arrayImplement a function to find the smallest element in rotated sorted array
    Languages
  • Tic-tac-toeBuild a tic-tac-toe game that is playable by two players
    Available frameworks
  • Deep OmitImplement a function that removes specified keys and their corresponding values from an object, including nested objects or arrays
    Languages
  • Find Element in Rotated ArrayImplement a function to find an integer in a rotated sorted array
    Languages
  • Image CarouselBuild an image carousel that displays a sequence of images
    Available frameworks
  • Job BoardBuild a job board that displays the latest job postings from Hacker News
    Available frameworks
  • Maximum Product in Contiguous ArrayImplement a function to find the subarray which has the largest product
    Languages
  • StopwatchBuild a stopwatch widget that can measure how much time has passed
    Available frameworks
  • Transfer ListBuild a component that allows transferring of items between two lists
    Available frameworks
  • Binary Search Tree Kth Smallest ElementImplement a function to find the kth smallest node in a BST
    Languages
  • Binary Search Tree Lowest Common AncestorImplement a function to find the LCA in a binary search tree
    Languages
  • Count Islands in a GridImplement a function to count distinct islands in a 2D binary grid
    Languages
  • Delete Nth Node from End of Linked ListImplement a function to delete the nth node from the end of a linked list
    Languages
  • Distinct Paths in GridImplement a function to calculate distinct paths for a robot moving on an m x n grid