This is the array of javascript objects.
array= [
{id: "e60ff4a3", name: "Alex", work: "constructor"},
{id: "fbd59f52", name: "Morgan", work: "engineer"},
{id: "e60ff4a3", name: "Ana", work: "teacher"},
{id: "715f0686", name: "Smith", work: "doctor"},
{id: "715f0686", name: "David", work: "keeper"},
{id: "fbd59f52", name: "Emma", work: "nurse"},
]
I want the array will be seen like this:
array= [
{
id: "e60ff4a3",
info: [
{
name: "Alex",
work: "constructor",
},
{
name: "Ana",
work: "teacher",
}
]
},
{
id: "fbd59f52",
info: [
{
name: "Morgan",
work: "engineer",
},
{
name: "Emma",
work: "nurse"
}
]
},
{
id: "715f0686",
info: [
{
name: "Smith",
work: "doctor",
},
{
name: "David",
work: "keeper"
}
]
},
]
It's like the array has to break according to its id and a similar id's objects will be written into an array named 'info'. Kindly give me the solution to it. Thanks