Q) Find all the duplicated values in given array.
//input : [1,2,4,3,2,1,3]
//output: [1,2,3]
Solution)
var findDuplicates = (arr) => {
let newArr = arr.filter((e,i ,a) => a.indexOf(e) != a.lastIndexOf(e) )
return [...new Set(newArr)];
};
let nums = [1,2,4,3,2,1,3];
let reqArr = findDuplicates(nums);
console.log(reqArr);