📅  最后修改于: 2022-03-11 14:48:31.238000             🧑  作者: Mango
//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"