I have the following json object in javascript:
employeeRecords = [
{
"empID" : "7002",
"company" : "Google",
"group" : "Chrome",
"id" : "D-2005",
"city" : "New York",
"date" : "2018-05-01"
},
{
"empID" : "9002",
"company" : "Apple",
"group" : "iPhone",
"id" : "D-2014",
"city" : "Singapore"
"date": "2019-07-15"
},
{
"empID" : "7002",
"company" : "Google",
"group" : "Android",
"id" : "H-2007",
"city" : "London"
"date": "2018-05-01"
},
{
"empID" : "7002"
"company" : "Google",
"group" : "Android",
"id" : "K-2007",
"city" : "London"
"date": "2019-06-18"
},
{
"empID" : "9002",
"company" : "Apple",
"group" : "Laptop",
"id" : "N-2012",
"city" : "Japan"
"date": "2019-07-15"
}
]
The requirement is to group this json object, if the empID, company and the date is equal. If those key values are equal then the group field should be concatenated. I need to get this using JavaScript.
So the result should be like the following:
employeeRecords = [
{
"empID" : "7002",
"company" : "Google",
"group" : "Chrome-Android",
"id" : "D-2005",
"city" : "New York",
"date" : "2018-05-01"
},
{
"empID" : "9002",
"company" : "Apple",
"group" : "iPhone-Laptop",
"id" : "D-2014",
"city" : "Singapore"
"date": "2019-07-15"
},
{
"empID" : "7002"
"company" : "Google",
"group" : "Android",
"id" : "K-2007",
"city" : "London"
"date": "2019-06-18"
}
]
Any help to achieve this in JavaScript please?
Thanks in advance.




