Making Change
Friday February 20, 2009
What coins/notes do I need to use to pay $x.xx in change? JavaScript can give the answer.
If you have any sort of JavaScript processing in a form on your web page that deals with money then one of the things that you may be calculating is the amount of change that someone needs to be given. Rather than just presenting that as a single figure, wouldn't it be much friendlier if you could instead provide a list of the notes and coins that are needed to make up that change? This simple JavaScript will add that functionality to your processing. All you need to do is to set up an array containing a list of the coins and notes in your chosen currency (from smallest to largest) and pass in the amount of change to be given and this function will return an array containing the change required.
Making Change


No comments yet. Leave a Comment