function duplicates(arr) { const tmp = []; arr.sort((a,b)=>a-b) for(let i = 0 ; i<arr.length;i++){ if(arr[i] == arr[i+1]){ tmp.push(arr[i]) } } let tmp1 = [...new Set(tmp)] return tmp1 }