I have the below sample array.(original array has more than 200 elements)
var array = [
{
"clientid": "ID000002",
"accesstoken": "pllALEl3TlwLL9hHP938H",
"groupname": "ABC",
"ancestorid": "8982857550",
"stroyid": [
"IGN-EXM-001-PDF",
"IGN-EXM-002-PDF"
]
}, {
"clientid": "ID000002",
"accesstoken": "pllALEl3TlwpHOD4aTP38H",
"groupname": "EFG",
"ancestorid": "4705872914",
"stroyid": [
"APP-ENE-FIE-CON",
"APP-ENE-ASS-INS",
"APP-ENE-ASS-CAR",
"APP-ENE-MAT-REA"
]
}, {
"clientid": "ID000002",
"accesstoken": "pllALEl3TlwLL9hHP938H",
"groupname": "ABC",
"ancestorid": "8982857550",
"stroyid": [
"IGN-EXM-001-ZIP",
"IGN-EXM-002-ZIP"
]
}
]
Condition = if (client id && ancestor id are the same then merge the storyid) so the output should be like:
[{
"clientid": "ID000002",
"accesstoken": "pllALEl3TlwLL9hHP938H",
"groupname": "ABC",
"ancestorid": "8982857550",
"stroyid": [
"IGN-EXM-001-PDF",
"IGN-EXM-002-PDF",
"IGN-EXM-001-ZIP",
"IGN-EXM-002-ZIP"
]
}, {
"clientid": "ID000002",
"accesstoken": "pllALEl3TlwpHOD4aTP38H",
"groupname": "EFG",
"ancestorid": "4705872914",
"stroyid": [
"APP-ENE-FIE-CON",
"APP-ENE-ASS-INS",
"APP-ENE-ASS-CAR",
"APP-ENE-MAT-REA"
]
}]
Please help me with javascript code to achieve this.