Arrays
Data Types
Map/Reduce
Algorithms
Logic
const duplicates = a => a.reduce((r, v, i, l) => !r.includes(v) && l.indexOf(v) !== i ? [...r, v] : r, []);
function duplicates(arr) {var out = [];for(var x=0;x<arr.length-1;x++){var ch = arr[x];for(var y=x+1;y<arr.length;y++){var comp = arr[y];if (comp === ch && out.indexOf(comp) === -1){out.push(comp);break;}}}out.sort();return out;}- const duplicates = a => a.reduce((r, v, i, l) => !r.includes(v) && l.indexOf(v) !== i ? [...r, v] : r, []);