{}
run-icon
main.js
products = [ {"name": "Smartphone", "category": "eletrônicos", "price": 150, "discount": 0.10}, {"name": "TV", "category": "eletrônicos", "price": 300, "discount": 0.0}, {"name": "Camiseta", "category": "vestuário", "price": 50, "discount": 0.20}, {"name": "Notebook", "category": "eletrônicos", "price": 1200, "discount": 0.0}, {"name": "Fone de Ouvido", "category": "eletrônicos", "price": 80, "discount": 0.10}, {"name": "Cafeteira", "category": "eletrodomésticos", "price": 200, "discount": 0.0}, ] const r = products.filter(p => p.discount > 0).map(v => { return { ...v, price: v.price - v.price * v.discount } }) console.log(r)
Output