1 回答
米琪卡哇伊
TA贡献1998条经验 获得超6个赞
function filter(students) {
var obj = {};
var result = [];
for (var i = 0, len = students.length; i < len; i++) {
var item = students[i];
var groupid = item.groupid;
var groupname = item.groupname;
var id = groupid + groupname;
if (!id) continue;
var index = obj[id];
var current;
if (index) {
result[index].g_count++;
} else {
result.push({
g_id: groupid,
g_name: groupname,
g_count: 1
});
obj[id] = result.length - 1;
}
}
return result;
}
filter(students);
添加回答
举报
0/150
提交
取消