Created
August 5, 2018 21:54
-
-
Save akhilome/900d5f40a073a529fbb9b36ad02075e0 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
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