Dapatkan nilai duplikat dari array javascript
// This code was pasted by ProgrammerRimon, 2022-02-18
// Find dublicates numbers from array;
const a = [1,1,1,3,3,4,5,5,6,7,8,8,8,8,8,9,2];
function findDublicatesNumbersFromArray(a) {
var d = [];
for (let i = 0; i < a.length; i++) {
var ct = a[i];
var cmt = 0;
for(var x = 0; x<a.length;++x) {
if(ct === a[x]) {
cmt++
if(cmt > 1) {
d.push(a[i])
}
}
}
}
return d.filter((i, ix)=> d.indexOf(i) === ix);
}
console.log(findDublicatesNumbersFromArray(a))
Homely Hamerkop