Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

UpperCase every first letter in each word in str

text.replace(/(^w|sw)/g, m => m.toUpperCase());
Comment

python capitalize first letter of each word in a string

>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
Comment

Return the provided string with the first letter of each word capitalized

const mySentence = "freeCodeCamp is an awesome resource";
const words = mySentence.split(" ");

for (let i = 0; i < words.length; i++) {
    words[i] = words[i][0].toUpperCase() + words[i].substr(1);
}

words.join(" ");
Comment

Capitalize first letter of each word

const toTitleCase = str => str.replace(/(^w|sw)(S*)/g, (_,m1,m2) => m1.toUpperCase()+m2.toLowerCase())

console.log(toTitleCase("heLLo worLd"));
// Hello World
Comment

Capitalize the first letter of each word

const mySentence = "freeCodeCamp is an awesome resource";
const words = mySentence.split(" ");

words.map((word) => { 
    return word[0].toUpperCase() + word.substring(1); 
}).join(" ");
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery external script 
Javascript :: import json data in js file 
Javascript :: xhr request 
Javascript :: lodash filter object keys 
Javascript :: how to get the first letter of a string in jquery 
Javascript :: usenavigate react router dom v6 
Javascript :: javascript rtsp player 
Javascript :: react native scrollview detect end 
Javascript :: ajax post body parameters 
Javascript :: string to binary javascript 
Javascript :: javascript add hours 
Javascript :: react native release apk command 
Javascript :: relode div 
Javascript :: javascript ES6 destructure dynamic property name 
Javascript :: angular event emitter 
Javascript :: sass config.json vs code 
Javascript :: format time in moment 
Javascript :: jquery change text 
Javascript :: push notification javascript 
Javascript :: javascript set width percentage update 
Javascript :: angular checkbox disabled 
Javascript :: add month date now javascript 
Javascript :: extract words from string js 
Javascript :: add tailwind to create react app 
Javascript :: select document jquery 
Javascript :: install proptypes react 
Javascript :: react state hooks 
Javascript :: javascript run two functions at the same time 
Javascript :: set timeout javascript 
Javascript :: ecmascript 7 getmonth as 2 digits 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =