Arrays and objects: interview questions
Array methods written by hand, flattening, deduplicating, deep clone and deep equal, and reshaping objects. 41 questions from the Front End Interview Handbook. 18 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).
- Implement
Array.prototypefunctions:map,reduce,filter,sortArrays and objects · basicJavaScript 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
- Implement
JSON.stringify().Strings and parsing, Arrays and objects · advancedJavaScript 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
Array.prototypemethods (flat,map,reduce,concat) by yourself using JavaScript.Arrays and objects · reported at AppleJavaScript codingcheckednot tried - Implement a function which extends
Array.prototype.Arrays and objects, Functions, this and closures · reported at ByteDance/TikTokJavaScript 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 Squash Object — flatten a nested object into a single-level object with dot-separated keys.Arrays and objects · 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 - Deduplicate a list of messages without using an object or a
Set.Arrays and objects · reported at RedditJavaScript 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 - 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
- What's the difference between host objects and native objects?Arrays and objectsQuizhandbooknot tried
- Why is extending built-in JavaScript objects not a good idea?Arrays and objectsQuizhandbooknot tried
- What language constructions do you use for iterating over object properties and array items?Arrays and objectsQuizhandbooknot tried
- Explain the difference between mutable and immutable objects.Arrays and objects, UI componentsQuizhandbooknot tried
- Can you give an example for destructuring an object or an array?Arrays and objectsQuizhandbooknot tried
- Data Table (with extensions for sorting and filtering)Arrays and objects, UI componentsUser interface codingno answer yetnot tried
- Implement
Array.prototypefunctions likemap,reduce,filter,sort.Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried - Given an object and a filter function, write a function that recursively filters the object, returning only values which return
truewhen called with the filter function (likeArray.prototype.filterbut for objects).Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried - Implement a data table from an array of objects using HTML/CSS and JavaScript with searching and sortingArrays and objects, UI components · reported at AmazonCodingno answer yetnot tried
- Given a JSON object generate a file directory UIArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
- Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
- Given an array, return an array where each value is the product of the next two items: E.g.
[3, 4, 5]->[20, 15, 12]Arrays and objects · reported at AppleAlgorithmsno answer yetnot tried - Analyze arrays — know
push,pop,unshiftfrom memory.Arrays and objects · reported at AtlassianJavaScript codingno answer yetnot tried - Merge two sorted integer arrays, remove duplicates.Arrays and objects · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried
- Debug a Trello/Jira-style React board with lane categorization, filtering, sorting, and routing.Arrays and objects, React · reported at EthosUser interface codingno answer yetnot tried
- Implement a ChatGPT-style interface using a supplied function that streams response chunks.Arrays and objects · reported at OpenAICodingno answer yetnot tried
- Manipulate arrays with filtering and other transformations.Arrays and objects · reported at RedditJavaScript codingno answer yetnot tried
- Build a job board: fetch and display posts, add a "load more" button, then layer on infinite scroll using
IntersectionObserver, throttling on scroll, and deduping of fetched items.Async, promises and timers, Arrays and objects · reported at RipplingUser interface codingno answer yetnot tried - Forms and data transformations with React. Practice controlled inputs, validation, and manipulating arrays of records.Arrays and objects, React · reported at RipplingUser interface codingno answer yetnot tried
- Tech screen: vanilla JavaScript bug-fix. You are given a working but buggy file with several classes (the example reported was a shopping cart with review comments and a 5-star rating widget). One by one the interviewer tells you what the bug is (e.g. "the 5-star widget lets you review more than once") and you fix it. Bugs cover state manipulation, array handling, DOM updates. Open book — you can search online. At the end, they ask for an overall code review of the file: how you would have implemented the whole thing differently, what you'd change about data, state, and performance.Arrays and objects, The DOM · reported at SquarespaceUser interface codingno answer yetnot tried
- Merge or transform structured data while preserving earlier requirements.Arrays and objects · reported at StripeCodingno answer yetnot tried
- 2D-array variants (Karat first-round technical screen). The reported question was a snake-game-style problem on a 2D grid, followed by a harder variant (medium/hard) on the same array shape. Interviewers keep asking new variants if you finish — pace yourself.Arrays and objects, UI components · reported at X/TwitterJavaScript codingno answer yetnot tried
- What is the difference between
Array.prototype.mapandArray.prototype.forEach?Arrays and objects, Functions, this and closures · reported at X/TwitterQuizno answer yetnot tried