An exercise related to closures and js-calculator
Create an html5 single page app that looks like a cash register with these buttons. The cash register starts with $0.00
funds
[________________] <-----( display )
[7] [8] [9] [÷] [clear]
[4] [5] [6] [×] [get balance]
[1] [2] [3] [-] [deposit cash]
[0] [00] [.] [+] [withdraw cash]
[=]
( display )
is the primary ui that prints all results
[clear]
will clear the display
[get balance]
will display the current balance
[deposit cash]
will add the amount currently in the ( display )
to the cash register, then clears the display
[withdraw cash]
will remove the amount currently in the ( display )
to the cash register, then clears the display
Write all calculator logic in calculator.js
using the revealing module pattern
The module should be named Calculator
and should only be concerned with performing mathematical computation.
Write the rest of the logic to perform the necessary functions to achieve the goal.
You may create modules within cash_register.js
in order to separate concerns.
For example, the function of updating the ( display )
should be handled in one place, or one module, instead of interweaved throughout the spaghetti.
Write all html5 markup in index.html
You should import ./js/calculator.js
and ./js/cash_register.js
at the bottom of your <body>
tag.
you must have live-server
installed, if not then install it npm i -g live-server
from your project directory run
live-server