Why cant we do uppercase with following code… I tried a lot but the error is showing ‘0 is read-only’ . if i try to log each element there is no problem with that…so why cant we mutate it with following code
function titleCase(str) {
var arr = str.split(' ');
for (var i in arr){
arr[i][0] = arr[i][0].toLocaleUpperCase();
//or arr[i][0] = arr[i][0].toUpperCase();
}
let neww = arr.join(' ');
console.log(arr);
}
titleCase("I'm a little tea pot");