What is a commonly used way to iterate and change some parts of an array?
During the Mini Linter project I was thinking about Task 8c:
I started thinking about the best way and most commonly used way to iterate through an Array with the possibility of changing certain indices and did some experiments:
forEach loop (did not work)
for of loop (did not work)
forEach loop with additional parameter index and array (worked)
- map method (worked)
Now can someone explain to me why 1 and 2 do not work?
What is the most common approach to this?