I need help with the “Title Case A Sentence” algorithm problem.
Here is my code below. The outputs are right but the tests are not passing. Any ideas?
function titleCase(str) {
let newStr = str.split(' ');
let capitalizeString = '';
for(let i = 0; i < newStr.length; i++){
let tempString = newStr[i].toLowerCase();
capitalizeString += ' ' + tempString.charAt(0).toUpperCase() + tempString.slice(1);
}
return capitalizeString;
}