Title Case a Sentence, not accepted by freeCodeCamp

Tell us what’s happening:
Describe your issue in detail here.
My code is working properly as intended but But freeCodeCamp.org is not accepting it.

  **Your code so far**
function titleCase(str) {
console.log(str);
str = str.toLowerCase();
console.log(str);
let word = str.split(" ");
let line = [];
str = "";
for(let i in word) {
 line = word[i][0].toUpperCase() + word[i].slice(1);
 str += (line + " ");
}
console.log(str);
return str;
}

titleCase("I'm a little tea pot");
titleCase("sHoRt AnD sToUt");
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44

Challenge: Title Case a Sentence

Link to the challenge:

Your code doesn’t quite work properly.

Try this:

titleCase("***" + "HERE IS MY HANDLE HERE IS MY SPOUT" + "***");

Here is the correct line of code. You may want to use this array in the loop. Instead of assigning strings to the line var.

Sure, that’s one potential fix.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.