this is my input, i have an array where name key has value 'foo1' in multiple objects so i want unique object with respect to 'name' key value and other information on a separate array.
var array = [{
name: "foo1",
value: "val1",
status: "1"
}, {
name: "foo1",
value: "val2",
status: "0"
}, {
name: "foo1",
value: "val3",
status: "1"
}, {
name: "foo2",
value: "val4",
status: "1"
}];
and i want on output like below. Below array are unique by name key and other value and status key from all matching object store on new_obj key.
var output = [{
name: "foo1",
new_obj: [{
value:"val1",
status: "1"
}, {
value:"val2",
status: "0"
}, {
value:"val3",
status: "1"
}]
}, {
name: "foo2",
new_obj: [{
value:"val4",
status: "1"
}]
}];