Hello everyone! I have the page pretty much built, except I am trying to make the ‘add to cart’ work. I have included a Codepen link . https://codepen.io/tyler308956/pen/rNKLKrG
Problems:
I’m trying to create a variable to count the items in the shopping cart and initialize it to zero.
Create a variable to hold some html to create a delete button. You can use a span tag with a class of ‘del’ and text Remove
What I am confused with:
I know how to ‘create a variable’; however, creating a variable that ‘count[s] the items in the shopping cart’ is throwing me off.
I have created a variable (see Codepen link above) that has html to create a delete button. Is that correct?
Create an array of shopping cart items, initialise to an empty array
Whenever someone clicks an item
Push that item to the array
Then the count of the items in the shopping cart is the length of that array
Is there a specific reason you want to insert html with JS rather than having the delete button present in the html and manipulating the css display value with JS?