Correct answers marked as wrong

Tell us what’s happening:
My code returns the correct answers but it is marked as wrong.

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

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/101.0.4951.67 Safari/537.36 OPR/87.0.4390.58

Challenge: Title Case a Sentence

Link to the challenge:

Double check all whitespace. You shouldn’t have any extra whitespace.

1 Like