Arrays & Iterables
Deduplicate Array by Iteratee
mediumJS SpecificJS / TS3 tests
Problem Statement
Implement `uniqueBy(array, iteratee)` that returns a deduplicated array based on the value returned by `iteratee(item)` (or property name). Keeps the first occurrence of each key.
Examples
Example 1:
uniqueBy([{ id: 1 }, { id: 2 }, { id: 1 }], 'id'); // [{ id: 1 }, { id: 2 }]
Example 2:
uniqueBy([1.2, 2.4, 1.7], Math.floor); // [1.2, 2.4]JavaScript & TypeScript starter code included
Run this as a live interviewPractice solo
3 test cases. No second person needed.