I have array of object Expected result: I use reduce() method to group the objects in an array by ‘group’ and calulate sum: How to group object of Array by key ‘group’ and calulate average?. I tried: But Expected result: Answer You could simply use reduce to get the total of age groups. And use object.keys length to get the
Tag: average
How to compute the sum and average of elements in an array? [duplicate]
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. This question already has answers here: How to find the sum of an array of numbers (59 answers) Closed 3 months ago. I am having problems adding all the