176
rated 0 times
[
180]
[
4]
/ answers: 1 / hits: 16535
/ 7 Years ago, fri, april 28, 2017, 12:00:00
I have an array of objects like below:
var array =
[
{name:abc,age:20}
{name:abc,age:20}
{name:abc,age:20}
{name:xyz,age:21}
{name:xyz,age:21}
]
I want to count the number of occurrences of distinct values like:
[3,2]
Assuming abc
has 3 occurrences and xyz
has 2 occurrences.
I am doing it in reactjs
. I am able to get distinct values like [abc,xyz]
using this answer.
ES6 syntax is preferred.
More From » arrays