Please help, why can’t the challenge accept my code? I know my code is way too long compared to the provided solutions, but my console provides the same output.
function titleCase(str) {
let splitStr = str.split(" ");
let upperArr = [];
let lowerArr = [];
let newTitle = ""
for (let i = 0; i < splitStr.length; i++) {
lowerArr.push(splitStr[i].toLowerCase());
upperArr.push(splitStr[i][0].toUpperCase());
newTitle += lowerArr[i].replace(/./, upperArr[i]);
newTitle += " ";
}
return newTitle;
}
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
Challenge Information:
Basic Algorithm Scripting - Title Case a Sentence