Skip to content

Instantly share code, notes, and snippets.

@henriquegogo
Created August 30, 2012 13:36
Show Gist options
  • Save henriquegogo/3528673 to your computer and use it in GitHub Desktop.
Save henriquegogo/3528673 to your computer and use it in GitHub Desktop.
Calc of number of occurence of letters in a string
var result = {};
"Your String".toUpperCase().split(" ").join("").split("").forEach(function(element, index, array) {
result[element] = (result[element] + 1 || 1)
});
console.log(result);
// You can remove '.join("").split("")' to calculate words occurence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment