Open Satjr opened 6 years ago
This works too:
var seen = [];
var dupes = [];
arr.forEach(function(value) {
if (seen.includes(value) && !dupes.includes(value)){
dupes.push(value);
}
seen.push(value);
});
return dupes;
I thought it would be better not to use Objects to answer this since this is an exercice about Arrays.