Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

capitalize first letter of all word typescript

//Altered, "capitalize all words of a string" (javascript by Grepper on Jul 22 2019) answer to compatible with TypeScript

var myString = 'abcd abcd';

capitalizeWords(text){
  return text.replace(/(?:^|s)S/g,(res)=>{ return res.toUpperCase();})
};

console.log(capitalizeWords(myString));

//result = "Abcd Abcd" 

Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #capitalize #letter #word #typescript
ADD COMMENT
Topic
Name
9+5 =