0
我有JavaScript對象數組鍵:獲取設置爲相同的值
objArray = [
{"date":"07/19/2017 12:00:00 AM","count":"1000","code":"K100"},
{"date":"07/21/2017 12:00:00 AM","count":"899","code":"C835"},
{"date":"07/23/2017 12:00:00 AM","count":"700","code":"C837"},
{"date":"07/23/2017 12:00:00 AM","count":"800","code":"K100"},
{"date":"07/23/2017 12:00:00 AM","count":"50","code":"C837"}
];
我想有相同的價值觀關鍵日期的所有值如下
- 刪除重複的日期值
- 將代碼值組合爲數組
- 總結重複日期值的計數值
這裏的預期輸出:
newObjArray = [
{"date":"07/19/2017 12:00:00 AM","count":"1000","code":"K100"},
{"date":"07/21/2017 12:00:00 AM","count":"899","code":"C835"},
{"date":"07/23/2017 12:00:00 AM","count":"1550","code":["C837","K100","C837"]}
]
還有我都試過的方式,但可以得到預期的輸出。任何人都可以幫助我處理我以獲得所需的輸出。
感謝ü這麼多! – user4324324