Easy
This question is a daily question and will count towards your daily streak.
You are building an e-commerce application and need to calculate the total revenue generated from a list of orders. Each order contains an amount and a discount (both in dollars). Use the provided orders array to calculate the total revenue after applying the discounts. What will the output be?
1const orders = [2 { amount: 200, discount: 20 },3 { amount: 150, discount: 15 },4 { amount: 400, discount: 50 }5];67const totalRevenue = orders.reduce((acc, order) => {8 const netAmount = order.amount - order.discount;9 return acc + netAmount;10}, 0);1112console.log(totalRevenue);