Hello, I have trouble on converting each first letter to upper case. So far i think the code is good (i even compare how my code works with the hint from FCC), but it wont work and the challenges even not passed. Please help me, is there any problem with my code or it was a bug from FCC itself
------My code
function titleCase(str) {
let newStr = str.split(' ');
let text = "";
for(let i = 0; i < newStr.length; i++){
let word = newStr[i].slice(0, 1).toUpperCase();
word += newStr[i].slice(1, newStr[i].length).toLowerCase() + " ";
text += word;
}
return text;
}
console.log(titleCase("I'm a little tea pot"));
Link to the challenge: