Easy
Calculate Shopping Cart Total with 20% Discount Using JavaScript Reduce Method
You need to calculate the total price of items in a shopping cart, applying a 20% discount to each item before summing them up. Which implementation correctly achieves this using JavaScript's reduce method?
1const cart = [2 { name: "Laptop", price: 1000 },3 { name: "Headphones", price: 200 },4 { name: "Keyboard", price: 150 },5];