Skip to content

Instantly share code, notes, and snippets.

@IAMIronmanSam
Created April 17, 2019 06:04
Show Gist options
  • Save IAMIronmanSam/add9828b2aeb467a197b3f9a444f384b to your computer and use it in GitHub Desktop.
Save IAMIronmanSam/add9828b2aeb467a197b3f9a444f384b to your computer and use it in GitHub Desktop.
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