my function only returns the first letter, although capitalized, and not the rest of the letters. What am I doing wrong?
Hello everyone. I have a very beginner question: I am trying to write a function that returns a string with the first letter capitalized (I will paste code below). However, my function only returns the first letter, although capitalized, and not the rest of the letters. What am I doing wrong?
function capitalize (string) {
return string.charAt(0).toUpperCase();
}
function capitalize (string) {
return string.charAt(0).toUpperCase();
}
No any search results
You already invited:
1 Answers
Alex - designer
Upvotes from:
string.charAt(0) is only returning the first character, then toUpperCase() returns that character to upper case.
You will need to build a new string from the first string and the rest of that string