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