This is a basic application that I am working on using React and Bootstrap. Here, The Grand Total is not changing when I update the quantity. I have attached the Sandbox link. Please let me know the mistake.
CodePudding user response:
the name of your variable is the problem products
const grandTotal = () => {
let total = 0;
for (let prd of product) {
total = prd.price * prd.quantity;
}
console.log(total);
return total;
};
products point to this variable
const products = [
{
sno: "123",
name: "Apple Watch",
price: 290,
quantity: 2
},
{
sno: "567",
name: "Samgung Watch",
price: 278,
quantity: 5
},
{
sno: "785",
name: "Cas",
price: 123,
quantity: 1
}
];