js - How to change one key's value based on another key's value in array of objects

后端 未结 4 998
眼角桃花
眼角桃花 2021-01-29 05:01

I have an array of objects like this:

var chartData = [{count: 0, idTag: \"24\"}
                 {count: 0, idTag: \"25\"}
                 {count: 0, idTag: \"         


        
4条回答
  •  借酒劲吻你
    2021-01-29 05:55

    I would rather maintain a intermediate hash with a "idTag" value as a key and its count as value, perform the operation with for loop, then generate charData from the intermediate hash once the for loop completes.

提交回复
热议问题