📜  javascript 将所有单词大写 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:31.438000             🧑  作者: Mango

代码示例6
export function capitalize(str: string, all: boolean = false) {
  if (all)
    return str.split(' ').map(s => capitalize(s)).join(' ');
  return str.charAt(0).toUpperCase() + str.slice(1);
}