Why my solution doesn't work?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function titleCase(str) {
let regex = /[\S]+/ig;
let tlstr = '';
let arr = str.toLowerCase().match(regex);
for (let i = 0; i < arr.length; i++) {
  arr[i] = arr[i][0].toUpperCase()+arr[i].slice(1);
  tlstr+= arr[i]+" ";
}
return tlstr;
}

console.log(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/101.0.4951.54 Safari/537.36

Challenge: Title Case a Sentence

Link to the challenge:

A simple way to see what might be wrong is to do a console.log of the return value before you return it. But that might not be clear on its own. I would suggest you wrap the return value in something, such as single quotes, to make it clear what is being returned.

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