Consider the following array of objects in javascript
const array = [
{ 10205: 2 },
{ 10207: 3 },
{ 10205: 2 },
{ 10207: 1 }
]
I would like to have it converted to
array = [
{ 10205: 4 },
{ 10207: 4 }
]
Consider the following array of objects in javascript
const array = [
{ 10205: 2 },
{ 10207: 3 },
{ 10205: 2 },
{ 10207: 1 }
]
I would like to have it converted to
array = [
{ 10205: 4 },
{ 10207: 4 }
]
2
Answers
Please use reduce function.