Tell us what’s happening:
When I am testing my code it works fine, but when I put it into FCC code area and run it returned right answer but wouldn’t submit the task.
Your code so far
function titleCase(str) {
let newStr = str.toLowerCase();
let finalStr = "";
let strArr = newStr.split(" ");
for(let i = 0; i < strArr.length; i++){
let st = strArr[i].replace(strArr[i][0], function(x) {return x.toUpperCase();});
finalStr += st + " ";
}
return finalStr;
}
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/83.0.4103.61 Chrome/83.0.4103.61 Safari/537.36.
Challenge: Title Case a Sentence
Link to the challenge: