Skip to content
Advertisement

How to access an Object’s values using arr.reduce() [closed]

I am trying to achieve the below:

JavaScript

Maybe I don’t understand how .reduce() works a 100%?

Advertisement

Answer

reduce method executes a callback function on each element of the array, so in your issue, on every iteration you have an object that contains name and value property. you can achieve your goal like this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement