Created
December 29, 2019 19:27
-
-
Save risingBirdSong/696a3515d3b4472f6f49abcde2af6346 to your computer and use it in GitHub Desktop.
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 duplicateCounta(text : string){ | |
return text | |
.toLowerCase() | |
.split('') | |
.reduce(function(a, l) { | |
a[l] = a[l] ? a[l]+1 : 1; | |
if(a[l] === 2) a.count++; | |
return a; | |
}, {count:0}).count; | |
} | |
// i solved this one in a similiar way using reduce, but this other solution from a code warrior is really good, had to save it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment