typescript function first letter uppercase code example
Example: 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"