hello i want to know how can i achieve this approach: i have this array of objects:
const array =[{district:1,buildings:["1","2"]},{district:1,buildings:["1","3"]},{district:2,buildings:["1","2"]}]
i want to merge the objects of the array + merging the buildings of the object with same district.
what should i get :
const array =[{district:1,buildings:["1","2","3"]},{district:2,buildings:["1","2"]}]
any help. thanks
note: this is can be done with for loop but i am looking for simpler approach.