Possible Issue With "Title Case a Sentence" Challenge [SPOILERS]

So I have been working on the “Title Case a Sentence” Challenge. I have created a script that would appear to produce the desired results that are listed on the challenge. I am going to copy and paste the code below and if someone can find a reason why my results are not being marked as correct I would be greatly appreciative. Please do not tell me how to fix the issue I enjoy a challenge, however, I can not tell why my answers are marked wrong. LAST NOTICE THIS IS MY SOLUTION CODE POSTED BELOW.
Thank you in advance.

function titleCase(str) {
  str = str.toLowerCase();
  var splitStr = str.split(" ");
  var titleCasedStr = "";
  for(i=0;i < splitStr.length;i++){
    titleCasedStr+= splitStr[i][0].toUpperCase();
    for(x=1;x < splitStr[i].length;x++){
      titleCasedStr+= splitStr[i][x];
    titleCasedStr+= " ";
  return titleCasedStr;
titleCase("sHoRt AnD sToUt");

The strings that you return have a trailing space.

Thank You that was the issue :slight_smile:

@camperextraordinaire Thank You for that piece of information. I can see it being very useful in the future.