capitalize mdn 1

capitalize mdn

let string = "hello World!";

let capitalizedString = string[0].toUpperCase() + string.slice(1);

// capitalizedString => Hello World!

Here is what the above code is Doing:
1. We create a variable called string and assign it the value of “hello World!”
2. We create a variable called capitalizedString and assign it the value of the first character of string, capitalized, plus the rest of the string.
3. We log capitalizedString to the console.

Similar Posts