📌  相关文章
📜  如何在javascript代码示例中检查字母是否大写

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

代码示例6
// program to convert first letter of a string to uppercase
function capitalizeFirstLetter(str) {

    // converting first letter to uppercase
    const capitalized = str.charAt(0).toUpperCase() + str.slice(1);

    return capitalized;
}

// take input
const string = prompt('Enter a string: ');

const result = capitalizeFirstLetter(string);

console.log(result);