Created
August 18, 2020 11:46
-
-
Save dmjcomdem/c651439fc448fa553d6ce5dbb791b2e8 to your computer and use it in GitHub Desktop.
Counting Duplicates
This file contains hidden or 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) { | |
return new Set(text.toLowerCase().match(/(.)(?=.*\1)/gi)).size | |
} | |
duplicateCount('Indivisibilities') // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment