I have below array of objects,
var parsedData = [
{
"ID": "16",
"DESCRIPTION": "SMAATO"
},
{
"ID": "26",
"DESCRIPTION": "BIDSWITCH"
},
{
"ID": "1572",
"DESCRIPTION": "BIDSWITCH"
}
]
i have removed duplicate from this using below code,
var flags = [], l = parsedData.length, i;
for( i=0; i<l; i++) {
if( flags[parsedData[i].DESCRIPTION]){
if(attribute.toLowerCase() == "supply"){
console.log("coming!!"+parsedData[i].ID+"---"+parsedData[i].DESCRIPTION);
}
continue;
}
flags[parsedData[i].DESCRIPTION] = true;
groups_array.push({
id: parsedData[i].ID,
text: parsedData[i].DESCRIPTION
});
}
but what i need to achive is, if id is differnt and description same means need to append id to first one and remove duplicate one like this,
[
{
"ID": "16",
"DESCRIPTION": "SMAATO"
},
{
"ID": "26,1572",
"DESCRIPTION": "BIDSWITCH"
}
]
How to get this one help me please...