Created
September 21, 2010 19:29
-
-
Save robotlolita/590356 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
// The outrageous totally awesomely unoptimized and hard way of doing | |
// the stuff :D | |
(function() { | |
var c, list | |
, letters = {} | |
, str = "ah, yes, for all the letters, you'll need" | |
+ "a loop... i read it wrong." | |
; | |
str.replace(/\s|\S/g, function(match) { | |
if (match && match[0]) { | |
c = match[0]; | |
letters[c] = (letters[c] || 0) + 1 } | |
}); | |
// prints everything... | |
list = Array.prototype.map.call(Object.keys(letters), function(key) { | |
return [letters[key], | |
key + ": " + letters[key]]; | |
}); | |
list.sort(); | |
return list.map(function(i){ return i[1] }); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment