Code works but doesn't pass the test. Can't figure out why

function titleCase(str) {
  var split = str.split(" ");
  var text = "";
  for (i = 0; i < split.length; i++) {
    text += split[i].charAt(0).toUpperCase() + split[i].slice(1).toLowerCase() + " ";
  }
    return text;
}
titleCase("I'm a little tea pot");