Below is the array that has 2 elements with Plan as name.I want to group the array using Javascript by name but the StartDate should be the minimum of all startdates that has name as Plan and EndDate should be max of all enddates that has name as plan.I want to group the elements and not sort them.
[{"Name":"Define","StartDate":"2015-04-09","EndDate":"2015-04-22"},
{"Name":"Plan","StartDate":"2015-04-22","EndDate":"2015-04-29"},
{"Name":"Plan","StartDate":"2015-04-30","EndDate":"2015-05-14"]}]
So my final array should be like below
[{"Name":"Define","StartDate":"2015-04-09","EndDate":"2015-04-22"},
{"Name":"Plan","StartDate":"2015-04-22","EndDate":"2015-05-14"]}]
I have got stucked in building the logic.Help appreciated.