easierbycode
2/14/2012 - 4:21 PM

Word Capitalize

Word Capitalize

// http://coderbyte.com/CodingArea/Results.php?ct=Letter%20Capitalize

function LetterCapitalize(str) { 

  return str.replace(/_/g, " ").toLowerCase().replace(/\w\S*/g, function (txt) {
    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  }); 
            
}

console.log( LetterCapitalize('ding dong foo') );