#Objects#Drills

JS Object Transformations Drill

Practice the object transformation patterns interviewers love — group by, flatten, invert, pick, omit, deep merge, and more. 15 quick drills with instant feedback.

By Pratik Rai

A focused drill set covering the most common object transformation patterns in JavaScript interviews. Write a solve(input) function for each problem and get instant pass/fail feedback. Covers Object.fromEntries, Object.entries, reduce, recursion, and more.

Goal: Complete all 15 object transformation drills. Aim to solve each without hints!

Frequently asked questions

Why drill object transformations specifically?
Because they are the most common small task in a frontend codebase — reshaping an API response into what a component needs — and because the same handful of built-ins solves nearly all of them. Fluency here shows up as speed in every other question.
Which methods cover most of the cases?
`Object.entries`, `Object.keys`, `Object.values`, `Object.fromEntries`, and `reduce`. The pattern that solves most problems is `Object.entries` to get pairs, `map` or `filter` over them, then `Object.fromEntries` to build the object back. Recognising when that pipeline applies is most of the skill.
When is reduce the better answer?
When you are building a shape that is not a one-to-one mapping — grouping by a key, counting occurrences, inverting to a many-to-one. `fromEntries` is cleaner when every input pair produces exactly one output pair; `reduce` earns its verbosity when they do not.
What tends to go wrong?
Mutating the input rather than building a new object, which breaks anything relying on reference equality. Losing key order assumptions — integer-like keys are ordered numerically first, whatever order you inserted them. And forgetting that `Object.entries` skips symbol keys and inherited properties entirely.

Related Challenges

Continue learning with these related challenges

View All
JavaScript

Recursive Object Evaluation

Implement a function that recursively traverses an object, evaluates functions with given arguments, and transforms keys to lowercase. Master recursive object traversal and type checking.

JavaScript · Recursion · ObjectsPratik Rai ·

JavaScript

Object.assign Polyfill

Implement Object.assign from scratch: copy own enumerable properties (including Symbols) from sources onto the target.

JavaScript · Objects · PolyfillsPratik Rai ·

JavaScript

Object.create Polyfill

Implement Object.create using the classic empty-constructor trick to set an object's prototype chain.

JavaScript · Objects · PrototypesPratik Rai ·