javascript modify array item for each code example
Example 1: forEach modify array JavaScript
arr.forEach(function(part, index) {
this[index] = "hello world";
}, arr); // use arr as this
Example 2: how to modify an array
let schedule = ['I', 'have', 'a', 'meeting', 'with'];
// adds 3 new elements to the array
schedule.splice(5, 0, 'some', 'clients', 'tommorrow');
console.log(schedule);
// ["I", "have", "a", "meeting", "with", "some", "clients", "tommorrow"]