capitalize first letter of all word typescript

Solutions on MaxInterview for capitalize first letter of all word typescript by the best coders in the world

showing results for - "capitalize first letter of all word typescript"
Nico
09 Apr 2016
1//Altered, "capitalize all words of a string" (javascript by Grepper on Jul 22 2019) answer to compatible with TypeScript
2
3var myString = 'abcd abcd';
4
5capitalizeWords(text){
6  return text.replace(/(?:^|\s)\S/g,(res)=>{ return res.toUpperCase();})
7};
8
9console.log(capitalizeWords(myString));
10
11//result = "Abcd Abcd" 
12
13
similar questions