[
{year: '1988', title: 'tile1', location: 'b'},
{year: '1988', title: 'title2', location: 'a'},
{year: '1989', title: 'title3', location: 'c'}
];
=>
const simpleArr2 = [
{
year: '1988',
places: [
{title: 'title1', location: 'b'},
{title: 'title2', location: 'a'},
]
},
{
year: '1989',
places: [{title: 'title3', location: 'c'}]
}]
simpleArr2.map(({year, places}) => ({year, ...places})) как-то так
Обсуждают сегодня