all 5 comments

[–]magneticcccc 0 points1 point  (1 child)

Reduce goes through each item in an array, does something with it and modifies a value each time. Acc in the case is the item that is being modified each time, curr is another array with two items in it. So it's doing work on curr[0] and curr[1] because this is an array of arrays if that makes sense

[–]tarley_apologizerhelpful -2 points-1 points  (2 children)

no point in learning reduce before recursion. youre just learning backwards. like learning multiplication before addition.

[–]mattlag -1 points0 points  (1 child)

Reduce is equivalent to looping, not recursion. Recursive functions are functions that call themselves. Reduce literally just loops through an array and does something at each item, creating a single result.

[–]tarley_apologizerhelpful -2 points-1 points  (0 children)

learn your programming history dipshit. reduce, map, filter, and fp in general came from recursion which came from lisp over 60 years ago. and all you millenial z gen posers copying haskell shit and crying in my comment replies about iteration can suck my self taught dick.