JavaScript practice questions with tests

Twenty-four JavaScript interview questions. Each one comes with a solution that works and the tests it has to pass. Free to read, nothing to sign up for. Most write-ups stop at code that looks about right. These show you what right actually means, because you can see all 104 tests it gets checked against.

Ordered by how often they come up, not by difficulty. Every solution here passes the tests shown on its page.

Implement debounce in JavaScript 9 tests closures, timers, higher-order functions Implement throttle in JavaScript 9 tests closures, timers, higher-order functions Implement Promise.all 4 tests promises, async coordination, error handling Implement JSON.stringify 2 tests recursion, type checking, serialization Implement curry in JavaScript 2 tests closures, partial application, higher-order functions Flatten an array without flat() 8 tests recursion, nested arrays Implement Array.prototype.reduce 6 tests array iteration, accumulator pattern, prototype methods Deep clone an object 2 tests recursion, object references Implement Array.prototype.filter 4 tests array iteration, this binding, prototype methods Implement an event emitter 2 tests classes, observer pattern, closures Implement memoize 6 tests closures, caching, higher-order functions Implement Function.prototype.call 5 tests this binding, prototype methods, rest arguments Implement deep equal 5 tests recursion, deep comparison Implement promisify 5 tests promises, callbacks, this binding Implement classnames in JavaScript 3 tests recursion, truthy/falsy checks Flatten a nested object 2 tests recursion, object flattening Group and merge an array of objects 4 tests array grouping, object immutability Limit promise concurrency 7 tests async/await, promises, concurrency control Type checking in JavaScript 3 tests type checking, prototypes Implement Promise.any 4 tests promises, error aggregation Deep omit keys from an object 2 tests recursion, object/array traversal, immutability Implement getElementsByTagName 2 tests recursion, tree traversal Format a list with commas 'and' 3 tests array methods, string formatting Filter an array of objects 5 tests array filtering, objects

Practise all 24 with the tests running

Practice Pad runs the same 104 cases against your own solution, in a real editor, on your Mac. Three levels per question, and an optional AI panel that explains why a test failed.

Download for macOS Free. Requires macOS 12 or later on Apple Silicon.