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

Need a quick refresher before you start? Review JavaScript in 30 Words for short concept definitions and code examples.

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

Practise all 24 with the tests running

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