//this does not work:
var animal = "moose";
animal[2]
animal[2] = 'z'
animal
//"moose"
//this kind of worked
console.log(animal.replace('o', 'z')); //"mzose"
console.log(animal.replace(/o/g, 'z')); //"mzzse"
//this works for this word
animal = animal.replace('oo', 'oz') //"mozse"
console.log(animal);
var animal = "moose"
animal = animal.slice(0, 2) + 'z' + animal.slice(3, animal.length);
console.log(animal);
var animal = "moose"
animal = animal.slice(0, 2) + 'z' + animal.slice(3)
console.log(animal);
//another way
var animal = "moose"
var str = "";
for (var i=0; i<animal.length; i++){
if (i == 2){
str += "z";
}else {
str += animal[i];
}
}
animal = str;
console.log(animal);