let arr = [
{
Category:'A',
Amount:,
},{
Category:'B',
Amount:,
},{
Category:'A',
Amount:,
},{
Category:'C',
Amount:,
},{
Category:'B',
Amount:,
},{
Category:'C',
Amount:,
},{
Category:'A',
Amount:,
},{
Category:'C',
Amount:,
}
]; let temp = {};
let end = []; for(let i = ; i < arr.length; i++){ let a = arr[i]; if(!temp[a.Category]){ end.push({
Category: a.Category,
data: [a]
});
temp[a.Category] = a; }else{ for(let j = ; j < end.length; j++){ let b = end[j]; if(b.Category == a.Category){
b.data.push(a);
break;
}
} }
}; console.log(end);
05-01 05:24