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

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

#1

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");

#2

The strings that you return have a trailing space.


#3

Thank You that was the issue :slight_smile:


#4

@Bloodypizza17 When you want to post code which has spoilers, one way to do that is by using spoiler tags on the line before and after of the code segment you want to hide.

[spoiler]
.
.
code is here
.
.
[/spoiler]

If you are using the three backticks to format your code, these tags would be on the lines outside those.


#5

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