javascript change all instances of character in string to uppercase code example
Example 1: capitalize first carater js
const capitalize = (s) => {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}
capitalize('flavio') //'Flavio'
capitalize('f') //'F'
capitalize(0) //''
capitalize({}) //''
Example 2: make first letter uppercase
const publication = "freeCodeCamp";
publication[0].toUpperCase() + publication.substring(1);