Help - Basic Algorithm Scripting: Title Case a Sentence

Tell us what’s happening:
Hi Folks,
I believe i solved this challenge… my solution doesnt match the solutions provided but ive met all the requirements asked for… i think.
maybe my code is a little different than what was expected…

Can anyone see the issue in this code?

Your code so far


function titleCase(str) {
  let strArray = str.split(" ");
  let newStr = "";
  for (let i = 0; i < strArray.length; i++) {
    strArray[i] = strArray[i].substring(0,1).toUpperCase() + strArray[i].substring(1,strArray[i].length).toLowerCase();
    newStr += strArray[i] + " ";
  }
  return newStr.trim() + ".";
}

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

Your browser information:

User Agent is: (Macintosh; Intel Mac OS X 10_15_7) Chrome/86.0.4240.75 .

Challenge: Title Case a Sentence

Link to the challenge:

Actually, you need not add . at end…

1 Like

oh… my… word…
I thought the full stop (period in USA) was part of the required output :man_facepalming:
Thanks so much.