(productId)
| 15 | } |
| 16 | |
| 17 | export function addToCart(productId) { |
| 18 | let matchingItem; |
| 19 | |
| 20 | cart.forEach((cartItem) => { |
| 21 | if (productId === cartItem.productId) { |
| 22 | matchingItem = cartItem; |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | if (matchingItem) { |
| 27 | matchingItem.quantity += 1; |
| 28 | } else { |
| 29 | cart.push({ |
| 30 | productId: productId, |
| 31 | quantity: 1 |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | saveToStorage(); |
| 36 | } |
| 37 | |
| 38 | export function removeFromCart(productId) { |
| 39 | const newCart = []; |
no test coverage detected