Here is an array of objects:
{
'data': [{
value: 1000,
year: 1990
},
{
value: 1001,
year: 1990
},
{
value: 1002,
year: 1990
},
{
value: 1003,
year: 1991
},
{
value: 1004,
year: 1991
}
]
}
The objective is to convert the above array into an object that looks like this:
{
'1990': [{
value: 1000,
year: 1990
},
{
value: 1001,
year: 1990
},
{
value: 1002,
year: 1990
}],
'1991':[{
value: 1003,
year: 1991
},
{
value: 1004,
year: 1991
}
]
}
Is there a way to achieve this in Javascript or Angular 4?