Title Case a Sentence Help0

Tell us what’s happening:
When I console.log the output it’s working, but for some reason, I’m not passing the tests.

Your code so far


function titleCase(str) {
let w = str.split(' ');
let x = '';
for (let i = 0; i < w.length; i++) {
  for (let j = 0; j < w[i].length; j++) {
    if (j == 0) {
      x += w[i][j].toUpperCase();
    } else {
      x += w[i][j].toLowerCase();
    }
  }
  x += ' ';
}
return x;
}

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

Challenge: Title Case a Sentence

Link to the challenge:

Hello there.

I added this in to show the issue:

console.log(titleCase("I'm a little tea pot"),"A");

Hope this helps

1 Like

Thank you very much!