Answers for "name case javascript"

6

title case javascript

function titleCase(str) {
    return str
        .split(' ')
        .map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase())
        .join(' ');
}
console.log(titleCase("I'm a little tea pot")); // I'm A Little tea Pot
Posted by: Guest on November-05-2020
-1

javascript string proper case

function toTitleCase(str) {
  return str.replace(
    /\w\S*/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"
Posted by: Guest on December-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language