I want to use a javascript function to capitalize the first letter of every word
eg:
THIS IS A TEST ---> This Is A Test
this is a TEST ---> Th
If you don't mind using a library, you could use Sugar.js capitalize()
capitalize( all = false ) Capitalizes the first character in the string and downcases all other letters. If all is true, all words in the string will be capitalized.
Example:
'hello kitty'.capitalize() -> 'Hello kitty'
'hello kitty'.capitalize(true) -> 'Hello Kitty'