iterate
Iterate over a callback n times
87 bytes
Usage
A bit like forEach
meets reduce
. Useful for running a function n
number of times to generate a value. The _.iterate
function takes a count (the number of times to run the callback), a callback function, and an initial value. The callback is run count many times as a reducer and the accumulated value is then returned.
Note, this is NOT zero indexed. If you pass a count
of 5 you will get an index of 1, 2, 3, 4, 5 in the callback function.