Created
August 30, 2012 13:36
-
-
Save henriquegogo/3528673 to your computer and use it in GitHub Desktop.
Calc of number of occurence of letters in a string
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
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