In my JSON database, I have a collection of objects where each one is assigned a specific value: either a, b, or c.
[
{
"id": 1,
"category": "a"
},
{
"id": 2,
"category": "b"
},
{
"id": 3,
"category": "c"
},
{
"id": 4,
"category": "a"
},
{
"id": 5,
"category": "a"
},
{
"id": 5,
"category": "b"
}
]
I want to show the following information:
There are a total of 6 items: a x 3, b x 2, and c x 1.
To calculate the total number of items, I know I can use objectsinmyjsondatabase.length
.
My question is, how can I determine the number of objects that have a specific value?