Jonah
0
Q:

replace specific values in array

// Replace 1 array element at index with item 
arr.splice(index,1,item);
13
array.splice(array.indexOf(valueToReplace), 1, newValue);
2
var fruits = [“banana”, “apple”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”];
fruits.splice(0, 2, “potato”, “tomato”);
console.log(fruits); // returns [“potato”, “tomato”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”]
0

New to Communities?

Join the community