Basic Algorithm(Title Case a sentence)

Tell us what’s happening:
Basically I want to ask what is the issue in this code ? I am getting all the outputs right.

  **Your code so far**

function titleCase(str) {
let strArr = str.split(' ');
let reqStr = '';
for (let i = 0; i < strArr.length; i++) {
  reqStr += strArr[i][0].toUpperCase();
  for (let j = 1; j < strArr[i].length; j++) {
  reqStr += strArr[i][j].toLowerCase();
  }
  reqStr += ' ';
}
return reqStr;
}

titleCase("I'm a little tea pot");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0

Challenge: Title Case a Sentence

Link to the challenge:

Hi @anuraag2002shukla !

Welcome to the forum!

You have a small spacing issue.

You can’t see it but there is actually extra space at the end of your string.
Luckily there is a string method to help with that.

Thank you very much !

1 Like

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