Console not passing even though console output seems right

Tell us what’s happening:
Hi,

I was wondering why my code is not working. I’ve console.logged it with all the examples and they all turned out as expected. I even tried my own crazy strings to see if it actually works but it still can’t pass the test. Is there something wrong with my code or is it just the test itself being picky?

Your code so far


function titleCase(str) {
let strArr = str.split(" ");
let strCap = "";
for (let i = 0; i < strArr.length; i++) {
  strCap += strArr[i].charAt(0).toUpperCase() +     strArr  
  [i].slice(1).toLowerCase() + " ";
}
return strCap;
}

console.log(titleCase("I'm a little tea pot"));  // output: I'm A Little Tea Pot

Challenge: Title Case a Sentence

Link to the challenge:

Just reading this (haven’t tested it) it looks like you’re maybe adding a space to the end of the string.

That actually makes a lot of sense lol! Thanks!