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).

  1. Implement Array.prototype functions: map, reduce, filter, sortArrays and objects · basicJavaScript codingcheckednot tried
  2. Implement Lodash functions: debounce(), throttle(), cloneDeep(), groupBy()Async, promises and timers, Functions, this and closures · basicJavaScript codingcheckednot tried
  3. Lodash's chunk()/map() with follow up of mapAsync(Promise.all) then mapWithChunksAsyncArrays and objects, Async, promises and timers · basicJavaScript codingcheckednot tried
  4. Convert all keys within an object into snake_case/camelCaseArrays and objects, Strings and parsing · basicJavaScript codingcheckednot tried
  5. Implement JSON.stringify().Strings and parsing, Arrays and objects · advancedJavaScript codingcheckednot tried
  6. Implement a polyfill of Array.prototype.reduce.Arrays and objects · reported at AdobeJavaScript codingcheckednot tried
  7. Find the leaders in an array (every element greater than all elements to its right).Arrays and objects · reported at AdobeJavaScript codingcheckednot tried
  8. Implement Array.prototype methods (flat, map, reduce, concat) by yourself using JavaScript.Arrays and objects · reported at AppleJavaScript codingcheckednot tried
  9. Implement a function which extends Array.prototype.Arrays and objects, Functions, this and closures · reported at ByteDance/TikTokJavaScript codingcheckednot tried
  10. Implement classnames — combine class names from strings, arrays, and conditional objects.Strings and parsing, Arrays and objects · reported at MetaJavaScript codingcheckednot tried
  11. Implement Squash Object — flatten a nested object into a single-level object with dot-separated keys.Arrays and objects · reported at OracleJavaScript codingcheckednot tried
  12. 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
  13. Deduplicate a list of messages without using an object or a Set.Arrays and objects · reported at RedditJavaScript codingcheckednot tried
  14. Dedupe a list of fetched items by ID using a Set of seen IDs.Arrays and objects · reported at RipplingJavaScript codingcheckednot tried
  15. Implement flatten on a nested array.Arrays and objects · reported at RipplingJavaScript codingcheckednot tried
  16. Flatten nested arrays, including a follow-up without recursion.Arrays and objects · reported at RobloxCodingcheckednot tried
  17. Flatten a nested array.Arrays and objects · reported at SalesforceJavaScript codingcheckednot tried
  18. LeetCode-style: "high five problem" variant (sort + average scores per student).Arrays and objects, Data structures and algorithms · reported at SalesforceJavaScript codingcheckednot tried
  19. What's the difference between host objects and native objects?Arrays and objectsQuizhandbooknot tried
  20. Why is extending built-in JavaScript objects not a good idea?Arrays and objectsQuizhandbooknot tried
  21. What language constructions do you use for iterating over object properties and array items?Arrays and objectsQuizhandbooknot tried
  22. Explain the difference between mutable and immutable objects.Arrays and objects, UI componentsQuizhandbooknot tried
  23. Can you give an example for destructuring an object or an array?Arrays and objectsQuizhandbooknot tried
  24. Data Table (with extensions for sorting and filtering)Arrays and objects, UI componentsUser interface codingno answer yetnot tried
  25. Implement Array.prototype functions like map, reduce, filter, sort.Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried
  26. Given an object and a filter function, write a function that recursively filters the object, returning only values which return true when called with the filter function (like Array.prototype.filter but for objects).Arrays and objects, Functions, this and closures · reported at AmazonCodingno answer yetnot tried
  27. 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
  28. Given a JSON object generate a file directory UIArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
  29. Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
  30. 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
  31. Analyze arrays — know push, pop, unshift from memory.Arrays and objects · reported at AtlassianJavaScript codingno answer yetnot tried
  32. Merge two sorted integer arrays, remove duplicates.Arrays and objects · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried
  33. 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
  34. Implement a ChatGPT-style interface using a supplied function that streams response chunks.Arrays and objects · reported at OpenAICodingno answer yetnot tried
  35. Manipulate arrays with filtering and other transformations.Arrays and objects · reported at RedditJavaScript codingno answer yetnot tried
  36. 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
  37. 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
  38. 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
  39. Merge or transform structured data while preserving earlier requirements.Arrays and objects · reported at StripeCodingno answer yetnot tried
  40. 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
  41. What is the difference between Array.prototype.map and Array.prototype.forEach?Arrays and objects, Functions, this and closures · reported at X/TwitterQuizno answer yetnot tried