Is there a way to group elements in an Array by their property value and put them into a new element, then push that new element into a new Array?
data = [
{status: 0,name:'a'},
{status: 0,name:'b'},
{status: 1,name:'b'},
];
var newData = [
{
id: 0,
name: 'a',
services: [
{id: 'a', name: 'a',status: 0}
]
},
{
id: 1,
name: 'b',
services: [
{id: 'b', name: 'b',status: 0},
{id: 'b', name: 'b',status: 1},
]
}
]