Two large projects I was recently involved with have required a great deal of front-end browser behavior and as a result i've become quite proficient with Javascript in the past few months. As the apps we use move further away from the desktop and onto the web, little nuggets like this will become more common. I've dabbled with a variety of frameworks and tend favor jQuery, but these can all be considered "framework independent" good ol' fashioned Javascript functions that anyone can use to enhance their user experience.
String Shortening Function
You can use this to shorten a string to a desired length (n), with a desired indicator (i).
APNumber Function
This extends the Number object with a method which will follow apnumber convention and convert numbers 0-9 to a string equivalent. 3 becomes three, 4 becomes four, etc... One downside to this is the fact that the strings are all capitalized, but work your magic young jedi (with a titlecase function) and you can overcome that.
Pluralize Function
This final function also extends the Number object, giving you the ability to make words plural based upon a variable value. 1 cherry, four cherries, etc... you get the deal.
It accepts two optional parameters, the singular and plural versions of the word you are trying to pluralize. Certain words would require no arguments such as dog vs. dogs, nugget vs nuggets, etc... but there are of course exceptions to everything in this marvelous language of ours... like child and children, cherry and cherries, etc...
I hope that you enjoy these little extensions of Javascript that can make your site or app a little friendlier to users. Follow me on Twitter to keep up with all of my adventures with Javascript.
