Remove duplicates from array based on values in ES6

I have an array as follows:

0: {id: 3, amount: 100, productId: 10, title: "Color/Red", variantChildren: Array(0)}
1: {id: 4, amount: 5, productId: 10, title: "Color/Green", variantChildren: Array(2)}
2: {amount: 0, variantChildren: {…}, title: "Color/Red"}
3: {amount: 0, variantChildren: {…}, title: "Color/Green"}
4: {amount: 0, variantChildren: {…}, title: "Color/Purple"}

I need to remove the duplicates that have the amount of 0. I’m trying to figure out how to do this with .filter() or .forEach()

So items [2] & [3] would get removed, and returned with a new array:

0: {id: 3, amount: 100, productId: 10, title: "Color/Red", variantChildren: Array(0)}
1: {id: 4, amount: 5, productId: 10, title: "Color/Green", variantChildren: Array(2)}
2: {amount: 0, variantChildren: {…}, title: "Color/Purple"}

117 thoughts on “Remove duplicates from array based on values in ES6”

  1. Pingback: cheapest viagra
  2. Pingback: viagra online usa
  3. Pingback: discount viagra
  4. Pingback: cialis france
  5. Pingback: cheapest cialis uk
  6. Pingback: cialis price
  7. Pingback: free viagra
  8. Pingback: sildenafil 1.5
  9. Pingback: generic viagra
  10. Pingback: viagra generic
  11. Pingback: viagra 10
  12. Pingback: cialis 5mg
  13. Pingback: super viagra
  14. Pingback: buy sildenafil
  15. Pingback: womens viagra
  16. Pingback: viagra jokes
  17. Pingback: viagra pour homme
  18. Pingback: viagra history
  19. Pingback: viagra sildenafil
  20. Pingback: viagra alternative
  21. Pingback: online viagra
  22. Pingback: roman viagra

Leave a Comment