I’m getting the correct results for the assignment but still not passing it. I thought at first it was because I had a space at the end, but I got rid of the space and it still isn’t passing. Can someone help me understand why my code won’t pass the challenge when it produces the correct outcome?
**Your code so far**
function titleCase(str) {
str = str.toLowerCase();
let arr = str.split(" ");
let newArr = [];
let newStr = "";
let newestStr = ""
for (let i = 0; i < arr.length; i++) {
let newStr = arr[i][0].toUpperCase();
for (let j = 1; j < arr[i].length; j++) {
newStr = newStr + arr[i][j];
}
newArr.push(newStr);
newestStr = newestStr + newArr[i] + " ";
}
newestStr.match(/\S$/);
return newestStr;
}
console.log(titleCase("I'm a little teapot"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Challenge: Title Case a Sentence
Link to the challenge: