Last active
July 1, 2019 11:25
-
-
Save indreklasn/7cd3f4d6ca5f5752f42441c49c37d3dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let count = 0 | |
const cartIncrementButton = document.getElementById('cartIncrement') | |
const cartDecrementButton = document.getElementById('cartDecrement') | |
const countElement = document.getElementById('count') | |
const buyButton = document.getElementById('purchase') | |
function init() { | |
countElement.innerHTML = count | |
cartIncrementButton.addEventListener('click', () => { | |
count++ | |
countElement.innerHTML = `${count}$` | |
}) | |
cartDecrementButton.addEventListener('click', () => { | |
if (count === 0) return | |
count-- | |
countElement.innerHTML = `${count}$` | |
}) | |
} | |
init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment