change values of one array with other in javascript code example
Example 1: foreach and replace item based on condition
arr.forEach(function(part, index, theArray) {
theArray[index] = "hello world";
});
Example 2: modify array js
let newArray = oldArray.map(funcToEachElem);