我有一个 javascript 对象,我通过 json 从数据库中获取它。有什么简单的方法可以根据同一个月计算值吗?(颜色并不重要)。所以结果将是这样的:
data = [
{
"value": 30,
"month": 8,
"color": "#49e630"
},
{
"value": 50,
"month": 7,
"color": "#5001dc"
},
{
"value": 100,
"month": 7,
"color": "#6365c3"
}
]
result = [
{
"value": 30,
"month": 8,
"color": "#49e630"
},
{
"value": 150,
"month": 7,
"color": "#6365c3"
}
]