Easy
This question is a daily question and will count towards your daily streak.
You are working on an application where you need to calculate the total revenue from a list of sales transactions. Each transaction is represented as an object with amount and currency. The following code attempts to calculate the total revenue in USD, assuming all amounts are already in USD.
1const transactions = [2 { amount: 150, currency: 'USD' },3 { amount: 200, currency: 'USD' },4 { amount: 350, currency: 'USD' },5 { amount: 50, currency: 'USD' },6];78const totalRevenue = transactions.reduce((acc, transaction) => {9 return acc + transaction.amount;10}, 0);1112console.log(totalRevenue);