Hello. I’m having issues with the Title Case a Sentence challenge. I’ve tried many “solutions” and none of them worked for me. Can you find the culprits in my code?
function titleCase(str) {
var lowercasedStr = str.toLowerCase();
var stringByWords = lowercasedStr.split(/\s/);
var finalArray = [];
for (var i = 0; i < stringByWords.length; i++) {
finalArray = stringByWords.map(stringByWords[i].charAt(0).toUpperCase());
}
return finalArray.join(" ");
}
titleCase("I'm a little tea pot");
Thanks in advance.