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