transaction calculator
# 🤝help
l
Who can help guide me thru how to write a javascript code which accepts 3 variables which are: userOrder, orderPrice, orderAmount and perform a transaction for user and also display the result in a variable I did this myself but I keep getting error This is my code below // Sample userOrder as an array of objects const userOrder = [ { productType: "apple", price: 1.99 }, { productType: "banana", price: 0.99 }, { productType: "orange", price: 2.49 }, // Add more products and prices as needed ]; // Function to calculate the total value of the user's transaction function calculateTotalValue(userOrder, orderAmount) { let totalValue = 0; // Iterate through the user's order and calculate the total value for (const order of userOrder) { const productType = order.productType; const price = order.price; // Check if the product type exists in the userOrder array if (userOrder.some(item => item.productType === productType)) { totalValue += price * orderAmount; } } return totalValue; } // Assuming orderAmount is the quantity the user wants to order const orderAmount = 3; // For example, the user wants to order 3 items // Calculate the total value of the user's transaction const transactionResults = calculateTotalValue(userOrder, orderAmount);