In this activity, you will complete the following app so that clicking each button will deduct the proper amount from the Account Balance.
See this simple click handler for example code.
- Download or fork/clone this Gist into your workspace. Alternatively, you can fork this Codepen.
- Using
document.querySelector
createElement
variables for eachbutton
displayed on the page. - Define a separate function for each of the actions listed in
eat-drink.js
, moving the relevant code into each respective function:- Drink beer ->
drinkBeer()
- Eat burger ->
eatBurger()
- Drink pop ->
drinkPop()
- Drink beer ->
- Using
Element.addEventListener()
, add aclick
listener to each button so that the proper function is invoked when the button is clicked. - Finally, refactor the code so that each
console.log()
instead displays the proper balance tooutputBalance
.
- This code is inspired by Introduction to functions by Steve Griffith