I would like to understand why I can't use this construction to capitalize de first letter of my strings of the array with JavaScript.
function capitalize(array){
for (let i = 0; i < array.length; i++){
array[i][0] = array[i][0].toUpperCase()
}
return lst;
}
I have already re-writed my code, to a way it works:
function capitalize(array){
for (let i = 0; i < array.length; i++){
array[i] = array[i][0].toUpperCase() + array[i].slice(1)
}
return array;
}
But I wanted to understand more deeply why