I would like to merge array objects, Below is the array if roundNo matches, should combine dates separated by comma and combing into a single object like mentioned as an expected output below. Date order needs to be preserved while combining.
Input:
const dataArray =
[{"date":"Dec 15—28","round":"Round 1","roundNo":"1"},
{"date":"Jul 1—7","round":"Round 1","roundNo":"1"},
{"date":"Jan 8—14","round":"Round 2","roundNo":"2"},
{"date":"Jan 7—10","round":"Round 2","roundNo":"2"}
{"date":"Jan 15—21","round":"Round 3","roundNo":"3"}]
Expected output
const dataArray =
[{"date":"Dec 15—28,Jul 1—7","round":"Round 1","roundNo":"1"},
{"date":"Jan 8—14,Jan 7—10","round":"Round 2","roundNo":"2"},
{"date":"Jan 15—21","round":"Round 3","roundNo":"3"}]