shopping website
javascript let cartItems = []; let cartTotal = 0; function addToCart(productId) { // Add product to cartItems array cartItems.push(productId); // Update cart total if (productId === 1) { cartTotal += 10.99; } else if (productId === 2) { cartTotal += 19.99; } // Update cart display const cartItemsElement = document.getElementById("cart-items"); const cartTotalElement = document.getElementById("cart-total"); cartItemsElement.innerHTML += "
Comments
Post a Comment