I wrote this code and the output seems to be right when I console.log it but it is not accepting it as an answer. Would anyone be able to explain why?
**Your code so far**
function titleCase(str) {
str = str.toLowerCase().split(" ")
var empt = "";
for(var i=0;i<str.length;i++){
var cap = str[i][0].toUpperCase();
empt += str[i].replace(str[i][0],cap)+" ";
}
return empt;
}
console.log(titleCase("I'm a little tea pot"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: