Hi I’m working with “Title Case a Sentence”. According to the “console.log” everything is OK and the strings are correct, but the test says it is not OK. My code is the following:
**Your code so far**
function titleCase(str) {
let newStr="";
const myArr = str.split(" ");
// console.log(myArr);
// console.log(myArr.length)
for(let i=0;i<myArr.length;i++){
myArr[i]=myArr[i].toLowerCase();
myArr[i]=myArr[i].replace(myArr[i], myArr[i].charAt(0).toUpperCase())+myArr[i].slice(1);
newStr+=myArr[i]+" ";
}
console.log(myArr);
console.log(newStr);
return newStr;
}
titleCase("I'm a little tea pot");
Thanks in advance
Regards.
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0
Challenge: Title Case a Sentence
Link to the challenge: