I'm trying to figure out how to iterate over an array in TypeScript and modify the iterator if necessary. The TypeScript logic I have so far looks like this:
for (let list_item of list) {
if (list_item matches condition) {
modify(list_item);
}
}
Unfortunately, this approach doesn't seem to work because TypeScript doesn't provide a mutable iterator. Is there a way to achieve this? I've considered enumerating over the array using something like
for (let list_item, index of list) { ... }
, but I'm not sure if that is valid.
You can see an example of the issue I'm facing here: goo.gl/5eDNsD