0

How to capitalize first letter of a string in JavaScript?

JavaScript
const capitalizeFirstLetter = (string) => {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

console.log(capitalizeFirstLetter('john'));
RUN
add comment
Suggest a different solution or add another example