I'm trying to arrange my current object, which looks like below
var myValues = [
{
client: "FIRE",
firstname: "Test",
id: "[email protected]",
arrangeid: "FIREFOX",
region: "FOP",
secondname: "Testy",
status: "Approved"
},
{
client: "FIRE",
firstname: "Test",
id: "[email protected]",
arrangeid: "BUZZZZZZ",
region: "FOP",
secondname: "Testy",
status: "Approved"
},
{
client: "PANTER",
firstname: "Panty",
id: "[email protected]",
arrangeid: "PANTER",
region: "PAN",
secondname: "mc panty",
status: "Approved"
},
{
client: "BAT",
firstname: "Bruce",
id: "[email protected]",
arrangeid: "BLACKBAT",
region: "BLK",
secondname: "Wyne",
status: "Approved"
}
]
So I've got this object, the first two ID's are the same but they got different arrangeid. I wanna be able to join the them to gather them together. Where the object looks something like this:
var myValues = [
{
client: "FIRE",
firstname: "Test",
id: "[email protected]",
arrangeid: ["BUZZZZZZ", "FIREFOX"],
region: "FOP",
secondname: "Testy",
status: "Approved"
},
{
client: "PANTER",
firstname: "Panty",
id: "[email protected]",
arrangeid: ["PANTER"],
region: "PAN",
secondname: "mc panty",
status: "Approved"
},
{
client: "BAT",
firstname: "Bruce",
id: "[email protected]",
arrangeid: ["BLACKBAT"],
region: "BLK",
secondname: "Wyne",
status: "Approved"
}
]
I have a jsfidle here, where i kinda get a result. Can it be done better, cleaner. Have I approached it correctly?