const arr = [
{
contry: 'Russia',
name: 'Alex',
age: '34',
},
{
contry: 'Russia',
name: 'July',
age: '22',
},
{
contry: 'USA',
name: 'Tom',
age: '32',
},
{
contry: 'USA',
name: 'Jack',
age: '74',
},
]
arr.reduce((acc, item) => {
const { contry, name, age } = item;
if(!acc.hasOwnProperty(contry)) acc[contry] = [{[name]:age}];
else acc[contry] = acc[contry].concat({[name]: age})
return acc
}, {})