Keep same order while removing the duplicate
// ES6 Set
function removeDups(arr) {
let noDup = [...new Set(arr)];
return noDup;
}
removeDups(["John", "Taylor", "John"]) // ["John", "Taylor"]
// Reduce
function removeDups(arr) {
let uniq = arr.reduce((a,b) => {
if (a.indexOf(b) < 0) a.push(b);
return a;
},[])
console.log(uniq)
}
removeDups(["John", "Taylor", "John"]) // ["John", "Taylor"]