function updateTotalBasket(){
var basketItems = document.querySelectorAll(".basket_item");
var quantity;
var price;
var totalPrice = 0.00;
basketItems.forEach((item) => {
quantity = item.querySelector(".quantity");
price = item.querySelector(".price");
console.log("quant : " + quantity.value);
console.log("price : " + price.innerHTML);
totalPrice += parseFloat(quantity.value) * parseFloat(price.innerHTML);
});
var totalPriceElement = document.querySelector("#totalPrice");
totalPriceElement.innerHTML = totalPrice.toFixed(2);
console.log(totalPrice);
}
Total Price should be 2953.48, but 2952.00 is coming. I think there is a problem with float multiplications. how can i fix this?