Code doesn't work on FCC but works on other consoles

Tell us what’s happening:
I would like to know why my code doesn’t work on FCC, but works on VS Code? Thanks in advance.

  **Your code so far**

function titleCase(str) {

let newArr = str.split(" ");

let solvedLine = "";

for (let i = 0; i < newArr.length; i++) {
  let CapitalizedWord =
    newArr[i].charAt(0).toUpperCase() + newArr[i].slice(1).toLowerCase();

  solvedLine = solvedLine + " " + CapitalizedWord;
}
return solvedLine;
}

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


  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Title Case a Sentence

Link to the challenge:

It looks like you are putting an extra space at the start of your string.

2 Likes

Thank you, that makes sense. I added .trim() to end of solvedLine. It solved the issue.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.