Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

Title Case a Sentence-Javascript

function titleCase(str) {
  return str.toLowerCase().replace(/(^|s)S/g, L => L.toUpperCase());
}
Comment

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(" ");
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: get params js 
Javascript :: how to sort by newest document mongoose 
Javascript :: loop 
Javascript :: check if array javascript 
Javascript :: get local storage javascript 
Javascript :: javascript replace part of string 
Javascript :: create a new input with type checkbox javascript 
Javascript :: last field prisma 
Javascript :: Regex port number 
Javascript :: split array into chunks 
Javascript :: js fake promise with timeout 
Javascript :: javascript canvas mousemove 
Javascript :: delegate jquery 
Javascript :: reactdom is not defined 
Javascript :: confirm message in jquery 
Javascript :: before in material ui style 
Javascript :: js canvas draw polygon 
Javascript :: get iso date javascript 
Javascript :: if string javascript 
Javascript :: onchange select dropdown jquery 
Javascript :: for char in string javascript 
Javascript :: wordpress header script add 
Javascript :: mongoose connection nodejs 
Javascript :: d3.js clear svg 
Javascript :: js get object by id from array 
Javascript :: javascript round to 2 decimal places 
Javascript :: how get a json object from an api in javascript 
Javascript :: discord.js get attachment url 
Javascript :: How to change favicon in nextjs. 
Javascript :: js get paste text 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =