I have an array that contains objects. The array looks like this:
[
{
"number": "10a",
"person": "Velvet"
},
{
"number": "10b",
"person": "Edna"
},
{
"number": "11a",
"person": "Shionne"
},
{
"number": "11b",
"person": "Aifread"
},
]
I want to combine objects that have identical number property. For example, the first two objects have property number: "10a", and number: "10b". I want these to be combined such that the output becomes:
{
"10": {
"person": ["Velvet", "Edna"]
},
"11": {
"person": ["Shionne", "Aifread"]
}
}
I am not sure how to do it as it seems too complicated for me. I also looked over stackoverflow but can't seem to find a similar problem, hence, my post. Thanks for the help!
numberhas fixed length 3? If not ,it will be difficult to define similar