Having an array of objects where one key:value pair has duplicate values, I'm looking to eliminate the replicated values within each object.
For instance, I need to trim the duplicate values from mapDataWithDuplicate
, as shown below:
mapDataWithDuplicate=[
{
lat: "39.562686920166",
lng: "-105.106826782227",
storeId: "0839",
stopId: "12,1,12,23,23"
},
{
lat: "39.6455154418945",
lng: "-105.339477539063",
storeId: "0010",
stopId: "24,2,13,24,13,2,13,24,24"
}
]
The goal is to remove duplicate values from stopId and arrange it in ascending order. Any assistance would be greatly appreciated.
The expected output should resemble this:
mapDataWithDuplicate=[
{
lat: "39.562686920166",
lng: "-105.106826782227",
storeId: "0839",
stopId: "1,12,23"
},
{
lat: "39.6455154418945",
lng: "-105.339477539063",
storeId: "0010",
stopId: "2,13,24"
}
]