Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript string proper case

function toTitleCase(str) {
  return str.replace(
    /wS*/g,
    function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    }
  );
}
// example
toTitleCase("the pains and gains of self study");
// "The Pains And Gains Of Self Study"
 
PREVIOUS NEXT
Tagged: #javascript #string #proper #case
ADD COMMENT
Topic
Name
7+5 =