I have an array with objects with operations.
I need to count the number of all operations and display them in a separate object.
Thank you in advance!
Array with objects with operations
"operationsHistory": [
{
"operationName": "buying",
"amount": 5,
},
{
"operationName": "deleting",
},
{
"operationName": "buying",
"amount": 5,
},
{
"operationName": "buying",
"amount": 2,
},
{
"operationName": "deleting",
},
{
"operationName": "deleting",
},
{
"operationName": "buying",
"amount": 5,
},
{
"operationName": "deleting",
},
{
"operationName": "buying",
"amount": 3,
}
]
What do I want to get
"operationsCount": {
"buying": 5,
"selling": 0,
"deleting": 4
},