Skip to content

Instantly share code, notes, and snippets.

@thejohnfreeman
Forked from wholypantalones/all.caps.killer.js
Created February 4, 2014 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejohnfreeman/8811854 to your computer and use it in GitHub Desktop.
Save thejohnfreeman/8811854 to your computer and use it in GitHub Desktop.
function toTitleCase(str) {
return str.replace(/_/g, " ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment