Answers for "title case function in 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
6

string to title case javascript

function titleCase(sentence) {
  let sentence = string.toLowerCase().split(" ");
  for (let i = 0; i < sentence.length; i++) {
    sentence[i] = sentence[i][0].toUpperCase() + sentence[i].slice(1);
  }
  
  return sentence.join(" ");
}
Posted by: Guest on April-10-2020
1

javascript title string

function toTitles(s){ return s.replace(/\w\S*/g, function(t) { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase(); }); }
var str = toTitles('abraham lincoln'); // Abraham Lincoln
Posted by: Guest on May-25-2020

Code answers related to "title case function in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language