Objects & Immutability

Invert Object Keys and Values

easyJS SpecificJS / TS3 tests

Problem Statement

Implement `invert(obj)` that returns a copy of the object where the keys have become the values and the values the keys. If values duplicate, later keys overwrite earlier ones.

Examples

Example 1:
invert({ a: '1', b: '2', c: '3' }); // { '1': 'a', '2': 'b', '3': 'c' }
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.