2. Capitalize the first character of a string
Although we don't have a dedicated method for this operation in JS, we can achieve it easily by rewriting the string with uppercased first character connected with the rest of the string. Take a look at the following example:
const name = "john"; const capitalized = name.charAt(0).toUpperCase() + name.slice(1); console.log(capitalized); // John
toUpperCase() function that works on characters to change the first char of the string. The rest characters are simply merged to that uppercased first one.