Created
April 17, 2019 06:04
-
-
Save IAMIronmanSam/add9828b2aeb467a197b3f9a444f384b 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 countUniqueString(arr){ | |
const lookup = {}; | |
for (let letter of arr) { | |
// if letter exists, increment, otherwise set to 1 | |
lookup[letter] ? lookup[letter] += 1 : lookup[letter] = 1; | |
} | |
return Object.keys(lookup); | |
} | |
countUniqueString('aabbbbbcccdefffff') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment