Hello guys, here is my problem: I finally solved the “Title Case a Sentence” bonfire, it returns me " I’m A Little Tea Pot" but I still can’t pass the challange, I guess maybe my code is a little weird and FCC doesn’t think that it is correct.
Here is my code :
function titleCase(str) {
var allLower = str.toLowerCase();
var words = allLower.split(" ");
var firstLetter;
var restOfTheString;
var final = "";
for(var i = 0; i < words.length; i++) {
firstLetter = words[i].split("").shift().toUpperCase();
restOfTheString = words[i].slice(1);
final += " " + firstLetter.concat(restOfTheString);
}
return final;
}
titleCase("I'm a little tea pot");
I know that probably it itsn’t the most common or fastest solution but I struggled to not search for the direct answer so I came up with this solution, what do you think of it?