0
I’m going through the following JSON:
[
{
"amount": 6,
"codes": [
"BRCH",
"ARSI",
"ENSI"
]
},
{
"amount": 6,
"codes": [
"BRCH",
"ARSI",
"ENSI"
]
},
{
"amount": 6,
"codes": [
"BRCH",
"ARSI",
"ENSI"
]
},
{
"amount": 2,
"codes": [
"BRSI",
"ARSI"
]
},
{
"amount": 2,
"codes": [
"BRSI",
"ARSI"
]
}
]
Well, I am using the javascript Map function to go through it and remove the repeated items and for that I check if the quantity and codes are equal:
let unique = new Map(itemsToClear.map(obj => [obj.amount, obj] && [obj.options.codes, obj]));
const uniques = Array.from(unique.values());
However, by using this form it is not able to scan the code array, there is a way to perform this action?
"because it contains a lot of junk and unnecessary data", that’s an excellent sign that you should craft a [mcve] eliminating all that noise.
– Woss
Thanks for the tip! I updated the question Minimalizando to be clearer.
– Tiago Paza
if you want to remove duplicates could create a new array only with single items, adding the items within the map, that such?
– Ricardo Pontual
How could I mount it then? I’m trying to accomplish this even with the Array.from function
– Tiago Paza