Modifing the Array values
//Modifying the Array values
let colors = ["blue", "red", "black"];
//Higher Order Array function map() doesn't work
//because it will be created a new element "x"
//and the value of that element will be modified
colors.map(x => x.replace(x.toUpperCase()));
console.log(colors); //Output: ["blue", "red", "black"]
//"for...of" loop doesn't work too, same reason.
for (color of colors){
color = color.toUpperCase();
}
console.log(colors); //Output: ["blue", "red", "black"]
//to modify the values of the origin Array,
//it will be needed an access to the direct
//placeholder of that value (colors[0...2]).
for (let i = 0; i < colors.length; i++){
colors[i] = colors[i].toUpperCase();
}
console.log(colors); //Output: ["BLUE", "RED", "BLACK"]