Medium

This question is a daily question and will count towards your daily streak.

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