Home >Backend Development >PHP Tutorial >javascript - How to accumulate poll values when the object code values in the array are the same
var arr = [
<code> {"code": "a", "poll": 7}, {"code": "b", "poll": 2}, {"code": "c", "poll": 18}, {"code": "a", "poll": 5}, {"code": "c", "poll": 12}, {"code": "a", "poll": 1} ]; </code>
var arr2 = [
<code>{"code": "a", "poll": 13}, {"code": "b", "poll": 2}, {"code": "c", "poll": 30}</code>
];
How to achieve the transformation from arr → to arr1, and the code value is not only a b c, but also adsdsd dsdsd a223, any value. How to achieve a similar transformation
var arr = [
<code> {"code": "a", "poll": 7}, {"code": "b", "poll": 2}, {"code": "c", "poll": 18}, {"code": "a", "poll": 5}, {"code": "c", "poll": 12}, {"code": "a", "poll": 1} ]; </code>
var arr2 = [
<code>{"code": "a", "poll": 13}, {"code": "b", "poll": 2}, {"code": "c", "poll": 30}</code>
];
How to realize the transformation from arr → to arr1, and the code value is not only a b c, but also adsdsd dsdsd a223, any value. How to realize a similar transformation