function calculateCost(products) {
        let cartCost = localStorage.getItem("totalCost");

        if (cartCost != null) {
            cartCost = Number(cartCost);
            localStorage.setItem("totalCost", cartCost + products.bestPrice);
        } else {
            localStorage.setItem("totalCost", products.bestPrice);
        }
    }
//Function to calculate total cost of cart
Function to calculate total cost of cart
Function to calculate total cost of cart
function calculateCost(products) {
        let cartCost = localStorage.getItem("totalCost");
        if (cartCost != null) {
            cartCost = Number(cartCost);
            localStorage.setItem("totalCost", cartCost + products.bestPrice);
        } else {
            localStorage.setItem("totalCost", products.bestPrice);
        }
    }
function calculateCost ( products ) { let cartCost = localStorage . getItem ( "totalCost" ) ; if ( cartCost != null ) { cartCost = Number ( cartCost ) ; localStorage . setItem ( "totalCost" , cartCost + products . bestPrice ) ; } else { localStorage . setItem ( "totalCost" , products . bestPrice ) ; } }
Function to calculate total cost of cart
Function to calculate total cost of cart