The below code is supposed to capitalize all the words in a string, but it is not working. The string is split and put back together appropriately except the toUpperCase method is not even working on the first character.
function titleCase(str) {
let strArray = str.split('');
strArray[0].toUpperCase();
for(let i=1;i<strArray.length;i++){
if(strArray[i-1]===' '){
strArray[i].toUpperCase();
}
}
return strArray.join('');
}
let titleStr = titleCase("i'm a little tea pot");
console.log(titleStr);