📅  最后修改于: 2022-03-11 15:01:36.956000             🧑  作者: Mango
// 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);