Javascript-how to accumulate poll values when the code values of objects in the array are the same

Source: Internet
Author: User
Vararr [{code ...} vararr2 [{code...}]; how to implement the transformation from arr to arr1, and how to implement a similar transformation of var arr = [if the code value is not only abc but also adsdsddsda223 [

{"Code": "a", "poll": 7 },{ "code": "B", "poll": 2 },{ "code ": "c", "poll": 18 },{ "code": "a", "poll": 5 },{ "code": "c", "poll ": 12 },{ "code": "a", "poll": 1}];

Var arr2 = [

{"Code": "a", "poll": 13 },{ "code": "B", "poll": 2 },{ "code ": "c", "poll": 30}

];
How to implement the transformation from arr → to arr1, and how to implement a similar transformation if the code value is not only a B c, but also an arbitrary value of adsdsd dsdsd a223

Reply content:

Var arr = [

{"Code": "a", "poll": 7 },{ "code": "B", "poll": 2 },{ "code ": "c", "poll": 18 },{ "code": "a", "poll": 5 },{ "code": "c", "poll ": 12 },{ "code": "a", "poll": 1}];

Var arr2 = [

{"Code": "a", "poll": 13 },{ "code": "B", "poll": 2 },{ "code ": "c", "poll": 30}

];
How to implement the transformation from arr → to arr1, and how to implement a similar transformation if the code value is not only a B c, but also an arbitrary value of adsdsd dsdsd a223

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.