Title Case a Sentence with join() not accepted

Tell us what’s happening:

It looks to me that the code I’ve written yields the correct answer. But freeCodeCamp is marking it as incorrect. Am I not seeing something? Could someone point out what requirement I’ve missed? I don’t think I have extra spaces at the beginning or end of my output, so I don’t think it’s that. I know there are similar topics already posted, but I didn’t see one that used join(), so I went ahead and made this post.

  **Your code so far**

function titleCase(str) {
let lower= str.toLowerCase();
let newArr=[];

let splitStr = lower.split(" ");

for (let i=0; i<splitStr.length; i++){
  newArr[i] = splitStr[i][0].toUpperCase();
  for (let j = 1; j<splitStr[i].length; j++){

let newStr = newArr.join(' ');
return str;

titleCase("sHoRt AnD sToUt");
  **Your browser information:**

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

Challenge: Title Case a Sentence

Link to the challenge:


console.log("|-----|" + titleCase("sHoRt AnD sToUt") + "|-----|");
1 Like

In case it isn’t clear, pay attention to what you are returning.


Gosh. Thanks, folx. Let’s chalk it up my headache earlier XD

1 Like

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