Problem, as an interviewer would state it:
"Implement objectMap(obj, fn) — transforming EVERY value of a plain object via fn, keeping the same keys, matching a real, common Array.prototype.map-equivalent for objects, built directly on Object.entries/Object.fromEntries."
Examples:
objectMap({a:1, b:2, c:3}, v => v * 2); // {a:2, b:4, c:6}
Clarifying questions expected:
- Should the callback receive the KEY (and index) as additional arguments, matching
Array.prototype.map's own real, familiar signature? - Should the original object remain completely untouched, with a genuinely new object returned?
- Should this bank's own already-covered
Object.fromEntriespolyfill be reused as a building block here?
Code / implementation expected: Yes — real, direct proof of correct value transformation, confirmation the key is correctly passed as the callback's second argument, and confirmation the original object is never mutated.