I have this array:
array = [
{
"id": 1,
"title": "Welcome to /r/artificial!",
"author": "CyberByte",
"ups": 128,
"comments": 16,
"created_at": "2017-06-19T20:16:35.000Z"
},
{
"id": 2,
"title": "Welcome",
"author": "Igor",
"ups": 12,
"comments": 06,
"created_at": "2017-06-19T20:16:35.000Z"
},
{
"id": 3,
"title": "Teste",
"author": "CyberByte",
"ups": 11,
"comments": 1,
"created_at": "2017-06-19T20:16:35.000Z"
},
]
I want to group them by author and sum the ups and comments. I'm trying to use reduce
.
How can I achieve this in plain javascript ?