Easy
How to Calculate Total Price of Shopping Cart Items Using JavaScript Array Reduce Method
You have a shopping cart with multiple items, each represented as an object in an array. Which method allows you to calculate the total cost of all items in the cart efficiently?
1const cart = [2 { name: "Laptop", price: 1200 },3 { name: "Mouse", price: 25 },4 { name: "Keyboard", price: 50 },5 { name: "Monitor", price: 200 },6];78// Calculate the total price of items in the cart9const totalPrice = cart.________(item => item.price);10console.log(totalPrice);