Title Case a Sentence won't pass second test

Tell us what’s happening:
This is my code it works when i try it in other editor but won’t work in FreeCodeCamp interface. It’s accurate enough to pass the second test but won’t.

Can someone give me some insight as to why this is happening?

Your code so far

var output = '';
function titleCase(str) {
  str = str.split(' ').map(function(item){
    item = item.replace(item[0],item[0].toUpperCase());
    newStr.push(item);
   //console.log(newStr);
  });
  output = newStr.join(' ');
  return output;
  
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence