i'm trying to regroupe a complexe array of object.
Here is my array :
[
{ scenario: "Treasury", diagnostic: "good results", action: "Manage Financial Recovery"},
{ scenario: "Treasury", diagnostic: "good results", action: "Analyze the impact of your investments"},
{ scenario: "Treasury", diagnostic: "Significant decline", action: "Ensure an adequate"},
{ scenario: "Treasury", diagnostic: "Significant decline", action: "Pilot your cash"},
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your business", action: "Valorize your labels"},
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your business", action: "Analyze the opportunity"}
{ scenario: "Turnover", diagnostic: "Improve trade efficiency of your firm", action: "Contacter un prestataire"}
];
I want to unify the array above to this one :
[
{
scenario: "Treasury",
diagnostics: [
{
diagnostic : "good results",
actions: [
"Manage Financial Recovery",
"Analyze the impact of your investments"
]
}
{
diagnostic : "Significant decline",
actions: [
"Ensure an adequate",
"Pilot your cash"
]
}
]
},
{
scenario: "Turnover",
diagnostics: [
{
diagnostic : "Improve trade efficiency of your business",
actions: [
"Valorize your labels",
"Analyze the opportunity"
]
}
{
diagnostic : "Improve trade efficiency of your firm",
actions: [
"Contacter un prestataire"
]
}
]
}
];
So i tried to unify my array using JSBin but i did not get the expected result, so what is the most efficient method to get an array of no duplicated ojects.