J. O.
0
Q:

foreach and replace item based on condition

arr.forEach(function(part, index, theArray) {
  theArray[index] = "hello world";
});
1
arr.forEach(function(part, index) {
  this[index] = "hello world";
}, arr); // use arr as this
0

New to Communities?

Join the community