6 lines
160 B
JavaScript
6 lines
160 B
JavaScript
const uniqueElementsBy = (arr, fn) =>
|
|
arr.reduce((acc, v) => {
|
|
if (!acc.some(x => fn(v, x))) acc.push(v);
|
|
return acc;
|
|
}, []);
|
|
module.exports = uniqueElementsBy; |