Files
30-seconds-of-code/test/uniqueElementsByRight/uniqueElementsByRight.js
2018-08-02 13:49:33 +03:00

7 lines
188 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;