Created
May 20, 2019 13:14
-
-
Save JoseGonzalez321/8f4a2d77dd193b22028952eabae4d39e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find duplicates in an array of ints | |
// IMO, a bit messier/complicated than should be. But it works. | |
function findDupes(arr) { | |
var counted = arr.reduce((all, item) => { | |
all[item] = (all[item] || 0) + 1; | |
return all; | |
}, {}); | |
return Object.keys(counted).filter(x => counted[x] > 1).map(x => parseInt(x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment