📜  javascript 大写首字母 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:20.027000             🧑  作者: Mango

代码示例6
const toTitleCase = (phrase) => {
  return phrase
    .toLowerCase()
    .split(' ')
    .map(word => word.charAt(0).toUpperCase() + word.slice(1))
    .join(' ');
};

let result = toTitleCase('maRy hAd a lIttLe LaMb');
console.log(result);