Why doesnt this work?

Just wondering why this doesnt work…

  **Your code so far**

function titleCase(str) {
let words = str.toLowerCase().split(" ");
for (let i = 0 ; i < words.length ; i++) {
return words;

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/89.0.4389.90 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:

The toUpperCase does not mutate the string “in place” that it is called on. Instead it returns a new value. You would need to assign this result to a variable to be able to capture the created string. Remember, strings are immutable, so you can not directly change characters in them. You can however create new strings from existing strings’ characters. This can be done via referencing the existing string’s characters or using string methods to capture the characters.

1 Like

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