Skip to content

Instantly share code, notes, and snippets.

@akhilome
Created August 5, 2018 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhilome/900d5f40a073a529fbb9b36ad02075e0 to your computer and use it in GitHub Desktop.
Save akhilome/900d5f40a073a529fbb9b36ad02075e0 to your computer and use it in GitHub Desktop.
function duplicateCount(text) {
const tracker = {};
const dupes = [];
for (const char of text.toLowerCase()) {
if (tracker.hasOwnProperty(char)) {
tracker[char]++;
} else {
tracker[char] = 1;
}
}
for (const prop in tracker) {
if(tracker[prop] > 1) dupes.push(prop);
}
return dupes.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment