Problem, as an interviewer would state it:
"Implement invert(obj) — swapping every key and value in a plain object, so that a value becomes a key and its original key becomes the new value, matching lodash's own well-known _.invert behavior."
Examples:
invert({a: "x", b: "y", c: "z"}); // {x: "a", y: "b", z: "c"}
Clarifying questions expected:
- If two different keys share the SAME value, which of the two original keys should genuinely win in the inverted result?
- Should the original object remain completely untouched, with a genuinely NEW object returned?
- What should happen to a value that is not naturally string-like, like a number — does it need to be coerced?
Code / implementation expected: Yes — real, direct proof of a basic key/value swap, a duplicate-value collision case, and confirmation the original object is never mutated.