I want to convert one data array to another array with new change means, if id match then push data into current one otherwise create new object with second id
let finaldata=[]
let data =[{id:1,name:"meet"},{id:2,name:"raj"},{id:1,name:"hari"},{id:3,name:"hari"},{id:2,name:"ram"}]
//I want this below array how can I archive this.?
finaldata= [ { id: 1, names: [ 'meet', 'hari' ] },
{ id: 2, names: [ 'raj', 'ram' ] },
{ id: 3, names: [ 'hari' ] }]