[Solved] Correctly build a filter function without DRY issue

And instead of forEach() we’ve been using filter() and reduce() here; these are other native methods to iterate over an array, but they also return a filtered array (such as by a certain category property) and a single value (such as an HTML string), respectively.

Ahhh moment… yes this makes a little more sense now m3g4p0p… filter and reduce, wasn’t to sure what they were exactly doing, thanks for the links.

this would be calling catFunction() from within itself

Recursion = When a function calls itself until it dosen’t (also as you mention above) read this today and thought the catFunction() was a Recursive Function.

So are you saying its not a Recursive Function because we’re using filter and reduce, otherwise it would be?

…so why not just use this one

Yes as shown in the latest fiddle example, this works good now.

I think in this instance now that it’s working, keep things how they are… as the saying goes “over engineer things

Lots information now which I’ll digest :sunglasses: