Title Case a Sentence output correct but still wrong?

Tell us what’s happening:

Hi I was hoping someone could tell me why this code isn’t right, It returns what I want correctly each time, but the website will not recognize it as being correct. Thanks!

Your code so far

function titleCase(str) {
  var sent=str.split(" ");
  var newSent='';
  for(i=0; i<sent.length; i++){
    newSent+=sent[i].substring(0, 1).toUpperCase()+sent[i].substring(1).toLowerCase()+" ";
  }
  return newSent;
}

titleCase("I'm a little tea pot");

Your browser information:

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

Link to the challenge:

Text that you return contains a whitespace character at the end, you can use trim to get rid of it.

Thanks a ton man, I probably should have seen that but hopefully I wont make the mistake again.