JavaScript by Radu TM β’ June 17, 2022
// this is an array of emoji fruits
var emojiFruits = ["π", "π", "π", "π", "π", "π", "π", "π", "π", "π"];
// this is the element we want to replace
var oldElement = "π";
// this is the element we want to replace it with
var newElement = "π";
// this is the index of the element we want to replace
var index = 0;
// replace the element at the specified index with the new element
emojiFruits[index] = newElement;
// log the updated array to the console
console.log(emojiFruits);
0
13.431
JavaScript by Radu TM β’ June 17, 2022
// array of emoji fruits
var fruits = ["π", "π", "π"];
// replace the element at index 1 (the second element) with "π" (banana)
fruits[1] = "π";
console.log(fruits); // ["π", "π", "π"]
0
13.431