// Sample userOrder as an array of objects
const userOrder = [
{ productType: "apple", price: 1.99 },
{ productType: "banana", price: 0.99 },
{ productType: "orange", price: 2.49 },
];
function calculateTotalValue(userOrder, orderAmount) {
let totalValue = 0;
for (const order of userOrder) {
const productType = order.productType;
const price = order.price;
if (userOrder.some(item => item.productType === productType)) {
totalValue += price * orderAmount;
}
}
I created the userOrder variable as an array of object and also the orderAmount as a variable of number but my code keeps giving me error
return Total value;
Firstly it says productType and price property does not existon type strip
Secondly it says it cannot find
name OrderAmount
Please help , I want to make a bot that can take an order from a user and also calculate and display the total to the user while storing it in a variable so i can export it to a google sheet
Please help
}
const transactionResults = calculateTotalValue(userOrder, orderAmount);