Can someone tell me why the below code is not passing the tests?
function titleCase(str) {
let words = str.split(’ ');
let result = ‘’; //console.log(words);
for (let i = 0; i<words.length; i++){
let firstStr = (words[i].slice(0,1)).toUpperCase();
let restOfStr = (words[i].slice(1,words[i].length)).toLowerCase();
result += (firstStr + restOfStr + ’ ')
} //console.log(result)
Can you check to see if you are producing an extra space at the end?
(In the log statement print out a character at the beginning and end to catch any unexpected spaces in the result)