Creating a simple cash register in javascript