I am new to programming, and I have been working on a javascript problem for the past couple of days.
Essentially, I need to write a function that takes in three parameters: an array arr
, a function fn
to be called repeatedly, and a value step
that signifies how many elements from the array to pass into fn.
For example, if step
were 3, then fn
would be called with the first 3 elements of arr
each as a positional argument. fn
will be called again with the next 3 arguments. fn
will continue to be called until there are no more elements to use as arguments from arr
. If the last group of arguments is less than step
, call the function fn
with whatever arguments are left.
I am pretty new to recursion. I have watched lots of videos and was attempting practice problems from my textbook and this was one of the ones I had trouble with.
Any help would be appreciated. Thanks!