Implement uniqueBy(arr, keyFn)
Write uniqueBy(arr, keyFn) that removes duplicates based on keyFn(item), keeping the first occurrence of each key and preserving order.
uniqueBy(
[{ id: 1 }, { id: 2 }, { id: 1 }],
(x) => x.id
); // [{ id: 1 }, { id: 2 }]