Javascript – stopping counter at 0
I have two functions that increment and decrement number of items by 1, but when I decrement I want to stop at 0? this are the functions const addToCart = (productId) => { setCartItems((prev) => ({ ...prev, [productId]: prev[productId] +…