Add iteration index to each function

it is useful, in many cases, to have the index of the current iteration.

ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach