filmov
tv
JavaScript array sum by object property

Показать описание
How to get the sum of values if they are properties of objects in JS array?
There is an array.
Array of objects.
Each object has the property “count”.
To get the total sum we need the reduce method.
Reduce method with two parameters.
First parameter is an arrow function.
Second parameter is the initial value.
And the answer is 42.
There is an array.
Array of objects.
Each object has the property “count”.
To get the total sum we need the reduce method.
Reduce method with two parameters.
First parameter is an arrow function.
Second parameter is the initial value.
And the answer is 42.