Medium

Calculate Total Revenue from Purchase Transactions Using JavaScript Array Reduce

You are working on a system that processes daily transaction logs. Each transaction has a type (e.g., "purchase" or "refund") and an amount. You need to calculate the total revenue, defined as the sum of all amounts for transactions with the type of "purchase". Using the transactions array, what is the correct way to calculate the total revenue?

Choose an option below