0
我有一个JSON对象数组这样分组概括
var scores= [{sectionid:1,sectiontitle:'Section1',score:5},
{sectionid:1,sectiontitle:'Section1',score:15},
{sectionid:1,sectiontitle:'Section1',score:7},
{sectionid:1,sectiontitle:'Section1',score:4},
{sectionid:2,sectiontitle:'Section2',score:5},
{sectionid:2,sectiontitle:'Section2',score:45},
{sectionid:2,sectiontitle:'Section2',score:13},
{sectionid:3,sectiontitle:'Section3',score:6},
{sectionid:3,sectiontitle:'Section3',score:23},
{sectionid:3,sectiontitle:'Section3',score:9},
{sectionid:3,sectiontitle:'Section3',score:12},
{sectionid:3,sectiontitle:'Section3',score:55},
{sectionid:4,sectiontitle:'Section4',score:4},
{sectionid:4,sectiontitle:'Section4',score:35}];
但我需要得到这些组JSON对象数组与另一个变量分组总分就在里面。
因此所产生的变量应该是这样的
var result=[{sectionid:1,sectiontitle:'Section1',score:26},
{sectionid:2,sectiontitle:'Section2',score:63},
{sectionid:3,sectiontitle:'Section3',score:105},
{sectionid:4,sectiontitle:'Section4',score:39}];
我尝试使用各种功能的穿越得分变量。但发现很复杂。我们如何才能以最好,最快捷的方式使其成为可能
完美的我的朋友...谢谢! –