I have the following variable:
var allProducts = [
{"code": 1,"name": "productA", "category": ["fruits"],...},
{"code": 1,"name": "productA", "category": ["vegetables"],...},
{"code": 2,"name": "productB", "category": ["meat"],...},
...
]
So the only difference between the two repeated array of objects is the category; where in this example code: 1 is once mentioned with category: ["fruits"] and another time with category: ["vegetables"]. Now I want to remove the duplicate but before doing so; I would like to save all the categories of productA into one category: ["fruits", "vegetables"] so the final variable would look like this:
var allProductsCleaned = [
{"code": 1,"name": "productA", "category": ["fruits", "vegetables"],...},
{"code": 2,"name": "productB", "category": ["meat"]...},
...
]
object,keytype in the variable. It should be like this?var allProducts = [ {"code": 1,"name": "productA", "category": ["fruits"],...},...