upper scale first letter javascript code example
Example 1: capitalize first letter javascript
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo bar bag')); // Foo
Example 2: how to capitalize string in javascript
const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)