Skip to content
Advertisement

Tag: reduce

4th argument in reduce

Here is the function: The fourth argument to reduce is the array that we’re iterating over. I can log it and I get the correct result (10) see above. But when I try to use it and assign it to a variable I get an error(see above). Could someone please shed some light? Answer From Mozilla’s page, the fourth parameter

How to group nested array of objects in js

I have a nested array of objects. I’m trying to group product objects that have the same value. Each objects has a vendor property containing an email. I am trying to group the objects by matching vendor email This is how my database looks like: I am trying to do it with the reduce method but the problem is with

Advertisement