I am working with an array of objects that looks like this:
students = [
{
"name": "Ana Barbique",
"category":"B"
}
{
"name": "Marko Polo",
"category":"B"
}
{
"name": "Nick Harper",
"category":"A"
}
]
My goal is to create an array of objects in this format:
sum = [
{
"category": "A",
"count" : 1
}
{
"category": "B",
"count" : 2
}
]
Basically, I want to extract the categories from the students array along with their count. The order of the categories is not important. This is something I have not attempted before.