I feel maybe it’s the return line that isn’t working, maybe I can’t add toUpperCase to charAt?
Your code so far
function titleCase(str) {
var lowerCase = str.toLowerCase(); // make it all lowercase
var newStr = lowerCase.split(" "); // separate the strings
for (i = 0; i < newStr; i++) { // loop through all separated strings
return newStr[i].charAt(0).toUpperCase + newStr.slice(1); // return the first letter capitalized with the addition of the the rest of the string
}
}
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36
.
Challenge: Title Case a Sentence
Link to the challenge: