I need to process Array of Objects and format it as expected. How can I format array at this time?
Current Objects data
array = [
{
id: "1",
answer: "d"
},
{
id: "3",
answer: "a"
},
{
id: "3",
answer: "b"
},
{
id: "3",
answer: "c"
},
{
id: "4",
answer: "b"
},
{
id: "4",
answer: "c"
}
]
I want to format with javascript
formatArray = [
{
id: "1",
answer: ["d"]
},
{
id: "2",
answer: []
},
{
id: "3",
answer: ["a","b","c"]
}
{
id: "4",
answer: ["b","c"]
}
]
I need to process Array of Objects and format it as expected. How can I format array at this time?