Not working solution on "Title Case a Sentence"

Tell us what’s happening:
Hello;
Why this solution seems not working …?

  **Your code so far**

function titleCase(str) {
var result = "";
for (let w of str.toLowerCase().split(' '))
  result += " " + w.replace(w[0], w[0].toUpperCase());
return result;
}

titleCase("I'm a little tea pot");
  **Your browser information:**

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

Challenge: Title Case a Sentence

Link to the challenge:

Not to be cheeky, but it’s not working because it is not meeting the requirements.

If you put:

console.log("***" + titleCase("I'm a little tea pot") + "***");

you can see what the issue is. See if that points you in the right direction. If you get stuck again, check back for another hint.

1 Like