change all items in array if there is a match code example
Example 1: foreach and replace item based on condition
arr.forEach(function(part, index, theArray) {
theArray[index] = "hello world";
});
Example 2: foreach and replace item based on condition
arr.forEach(function(part, index) {
this[index] = "hello world";
}, arr); // use arr as this