question bank
Interview questions
450 questions from the Front End Interview Handbook. 62 have our own answer, built up basic to advanced and checked against the spec, with code that runs (how answers are checked). 98 more show the handbook's answer as a dashed blueprint until we check them. 9 link to a lesson that builds the idea.
- Implement
Array.prototypefunctions:map,reduce,filter,sortArrays and objects · basicJavaScript codingcheckednot tried - Implement Promise/Promise-related APIs:
Promise,Promise.all,Promise.anyAsync, promises and timers · basic · has a lessonJavaScript codingcheckednot tried - Implement Lodash functions:
debounce(),throttle(),cloneDeep(),groupBy()Async, promises and timers, Functions, this and closures · basicJavaScript codingcheckednot tried - Lodash's
chunk()/map()with follow up ofmapAsync(Promise.all) thenmapWithChunksAsyncArrays and objects, Async, promises and timers · basicJavaScript codingcheckednot tried - Convert all keys within an object into snake_case/camelCaseArrays and objects, Strings and parsing · basicJavaScript codingcheckednot tried
- DOM APIs:
document.getElementByClassName(),document.getElementByTagName()The DOM · basicJavaScript codingcheckednot tried - Observer patternPatterns: emitters, observers, stores · basicJavaScript codingcheckednot tried
- Write a templating engine that does variables substitution and simple conditionals.Strings and parsing · advancedJavaScript codingcheckednot tried
- Implement
JSON.stringify().Strings and parsing, Arrays and objects · advancedJavaScript codingcheckednot tried - Generate table of contents/outline from a HTML page (similar to Google Docs autogenerated outline).The DOM · advancedJavaScript codingcheckednot tried
- Given an API
getAllLinks(url)that returns all the links on a page, write a function that returns all descendant links (child URLs of child URLs, etc.). Handle edge cases: circular dependencies,getAllLinksreturning a promise, async efficiency, and time complexity.Async, promises and timers, Data structures and algorithms · reported at AdobeJavaScript codingcheckednot tried - Implement a polyfill of
Array.prototype.reduce.Arrays and objects · reported at AdobeJavaScript codingcheckednot tried - Find the leaders in an array (every element greater than all elements to its right).Arrays and objects · reported at AdobeJavaScript codingcheckednot tried
- Implement a custom React hook that uses
setInterval. Common gotcha: the interval double-fires unless you keep the callback in auseRefinstead ofuseState.React, Async, promises and timers · reported at AdobeJavaScript codingcheckednot tried - Write a simple promise.Async, promises and timers · reported at AirbnbJavaScript codingcheckednot tried
- Implement a Backbone-style
StoreDataclass with key/value pairs and change listeners. One variation included a globalchangelistener and requiredunsetto remove data while retaining subscriptions. Setting the attribute again should notify those listeners. SourcePatterns: emitters, observers, stores · reported at AirbnbJavaScript codingcheckednot tried - Implement
Array.prototypemethods (flat,map,reduce,concat) by yourself using JavaScript.Arrays and objects · reported at AppleJavaScript codingcheckednot tried - How can you execute an array of promises in sequence?Async, promises and timers · reported at AppleJavaScript codingcheckednot tried
- Know
Promise.anyfrom memory.Async, promises and timers · reported at AtlassianJavaScript codingcheckednot tried - Implement
Promise.all.Async, promises and timers · reported at ByteDance/TikTok, LyftJavaScript codingcheckednot tried - Implement a function which extends
Array.prototype.Arrays and objects, Functions, this and closures · reported at ByteDance/TikTokJavaScript codingcheckednot tried - Implement a polyfill of
Function.prototype.bind— handle thenewkeyword correctly.Functions, this and closures · reported at ByteDance/TikTokJavaScript codingcheckednot tried - Implement concurrency-limited async mapping. One earlier interview required a particular approach, so clarify scheduling constraints before coding.Async, promises and timers · reported at ByteDance/TikTokJavaScript codingcheckednot tried
- Implement a
composemiddleware function so that async middlewares like Koa-stylef1,f2,f3(each callingnext()) execute in the correct nested order.Functions, this and closures, Async, promises and timers · reported at ByteDance/TikTokJavaScript codingcheckednot tried - React-like VDOM but instead of creating DOM nodes, output an HTML string given an input object with
typeandattributes.React, The DOM · reported at ByteDance/TikTokJavaScript codingcheckednot tried - Fix a buggy
fetchhelper: the provided function may look right but doesn'treturnthe promise fromfetch(...). You're expected to spot it.Async, promises and timers, Network and APIs · reported at DoorDashJavaScript codingcheckednot tried - Implement
getByClassName()andgetByClassnameHierarchy()The DOM · reported at DropboxJavaScript codingcheckednot tried - How do you make a function that takes a callback function
fnand returns a function that callsfnon a timeout?Async, promises and timers, Functions, this and closures · reported at GoogleJavaScript codingcheckednot tried - DFS on HTML nodes.The DOM, Data structures and algorithms · reported at GoogleJavaScript codingcheckednot tried
- Implement
throttle, for example allowing an input function to run at most once every 50 milliseconds.Async, promises and timers, Functions, this and closures · reported at GoogleJavaScript codingcheckednot tried - Write a
getElementsByClassNamefunction.The DOM · reported at LinkedInJavaScript codingcheckednot tried - Implement memoization, then extend the behavior as requirements change.Functions, this and closures · reported at LinkedInJavaScript codingcheckednot tried
- Implement an Event Emitter (Emitter Pattern).Patterns: emitters, observers, stores · reported at MetaJavaScript codingcheckednot tried
- Implement
classnames— combine class names from strings, arrays, and conditional objects.Strings and parsing, Arrays and objects · reported at MetaJavaScript codingcheckednot tried - Implement a
Decryptionclass — focuses on managing async operations and a callback queue. The provideddecryptEncrypt(key, payload, callback)generates a new key per call; your class must enqueue callbacks and process them in order as decryption completes. (The name is misleading — it's an async-operations question, not a security question.)Async, promises and timers · reported at MetaJavaScript codingcheckednot tried - Find the identical DOM node in two identical trees: given a node in one tree, locate the equivalent node in the other tree by reference. Efficient solution: walk up via
parentNode, record the path, then replay the path in the other tree (avoids touching unrelated nodes vs. DFS/BFS).The DOM · reported at MetaJavaScript codingcheckednot tried - Implement a number/character pad like old flip phones — buttons where
2 = abc,3 = def, etc. Pressing the same key cycles through letters within a short time window; after a delay, the next press appends. e.g. press 2 →a, press 2 again →b, wait 1s and press 2 →ba, press 6 →bam.Async, promises and timers, Strings and parsing · reported at MicrosoftJavaScript codingcheckednot tried - Rabin-Karp string-matching DSA problem (recurring at Microsoft).Strings and parsing, Data structures and algorithms · reported at MicrosoftJavaScript codingcheckednot tried
- Implement Squash Object — flatten a nested object into a single-level object with dot-separated keys.Arrays and objects · reported at OracleJavaScript codingcheckednot tried
- Evaluate a basic arithmetic expression string like
"1+3-2"and print the output. Handle all edge cases (no BODMAS required).Strings and parsing · reported at OracleJavaScript codingcheckednot tried - Find common elements between two arrays — e.g.
arr1 = [1, 2, 2, 4, 5],arr2 = [3, 2, 4, 2]→[2, 2, 4]. Follow-up: extend to matrices instead of two arrays.Arrays and objects · reported at OracleJavaScript codingcheckednot tried - Intervals problem: design a class with related methods (insert, overlap, merge) over a list of intervals.Data structures and algorithms · reported at PalantirJavaScript codingcheckednot tried
- Given a text and a query of two words plus an integer
k, return the indices in the text where the distance between the two words is≤ k.Strings and parsing, Data structures and algorithms · reported at PalantirJavaScript codingcheckednot tried - "Can you win" — variant of LeetCode Jump Game I/II. Medium-level DSA, you should be able to solve 2 in 20-30 minutes.Data structures and algorithms · reported at PinterestJavaScript codingcheckednot tried
- Given an array of integers like
[1,2,0,4,3]and a starting index, returntrueif you can reach a0value. Each value is how many steps left/right you can move (you must take exactly that many). Wrap around from end to start when you run out of room. Solve recursively with visited-index tracking, then convert to an iterative queue-based solution as a follow-up.Data structures and algorithms · reported at PinterestJavaScript codingcheckednot tried - Given a stream of comments, detect inappropriate language. Requires a trie data structure.Data structures and algorithms, Strings and parsing · reported at PinterestJavaScript codingcheckednot tried
- Deduplicate a list of messages without using an object or a
Set.Arrays and objects · reported at RedditJavaScript codingcheckednot tried - Read HTML form data and construct a JSON object.The DOM, HTML · reported at RedditJavaScript codingcheckednot tried
- Implement
Event Emitter.Patterns: emitters, observers, stores · reported at RipplingJavaScript codingcheckednot tried - Implement a hand-rolled
throttle; one screen prohibited library imports.Async, promises and timers, Functions, this and closures · reported at RipplingJavaScript codingcheckednot tried - Dedupe a list of fetched items by ID using a
Setof seen IDs.Arrays and objects · reported at RipplingJavaScript codingcheckednot tried - Implement
flattenon a nested array.Arrays and objects · reported at RipplingJavaScript codingcheckednot tried - Implement
Function.prototype.bind.Functions, this and closures · reported at RipplingJavaScript codingcheckednot tried - Implement an event emitter progressively in 3 stages of increasing complexity. Senior / staff candidates are expected to clear all 3 stages.Patterns: emitters, observers, stores · reported at RobinhoodJavaScript codingcheckednot tried
- Flatten nested arrays, including a follow-up without recursion.Arrays and objects · reported at RobloxCodingcheckednot tried
- Flatten a nested array.Arrays and objects · reported at SalesforceJavaScript codingcheckednot tried
- LeetCode-style: "high five problem" variant (sort + average scores per student).Arrays and objects, Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
- LeetCode-style: calculate the distance a robot has moved given a sequence of instructions.Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
- Implement a rate limiter attribute/decoration/annotation on top of an API endpoint. Caps to N requests per minute with a rolling window. Source A and Source BFunctions, this and closures, Network and APIs · reported at UberJavaScript codingcheckednot tried
- Implement an async process queue with concurrency control. Follow-up: handle async-task failures by accepting an error callback handler.Async, promises and timers · reported at UberJavaScript codingcheckednot tried