Design comparison
SolutionDesign
Solution retrospective
i am still stuck at making some other functionality work, i dont mind getting help from pro pls
Community feedback
- @vickievienPosted about 2 years ago
For the counter and add to cart functionality, consider updating the orderNumber only when addToCart is clicked. And this orderNumber should be the SUM of what is already in the cart plus what they want to add (I had it like yours until a family member made a comment about how it should be adding up not only a counter)
So something along the lines of this:
- capture the count (like you have with the +/-)
- create a cartSum variable (or whatever you'd like to call it)
- on click of the addToCart element, addCart function should be a sum
cartSum += count
then append the cartSum to the orderNumber (something like this:addCart.innerHTML = cartSum += count
)
Syntax may be a bit wonky but hopefully these steps give you a high level of how functionality could be improved!
Marked as helpful1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord