I have a data where each emp has manager, i’m trying to get an array with emp with perticular manager. for ex: Manager1 with array of all his emp and Manager2 with all his emp. i have pasted a sample out.how can i get that?
const response = [
{
"emp":{
"firstName":"Abhi"
},
"manager":{
"firstName":"Ashok"
}
},
{
"emp":{
"firstName":"Lokesh"
},
"manager":{
"firstName":"Ashok"
}
},
{
"emp":{
"firstName":"Harish"
},
"manager":{
"firstName":"Ashok"
}
},
{
"emp":{
"firstName":"Kaushik"
},
"manager":{
"firstName":"Sunil"
}
},
]
Sample output i need:
[
{
"manager":"Ashok",
"emp":[
{
"firstName":"Abhi"
},
{
"firstName":"Lokesh"
},
{
"firstName":"Harish"
}
]
},
{
"manager":"Sunil",
"emp":[
{
"firstName":"Kaushik"
}
]
}
]