This is almost a completely new version of the Change maker script that I originally wrote back in 2007. The script basically takes any amount of money and provides you with a list of the smallest combination of coins and notes that will make up that amount. Since the actual coins and notes differ between countries the script allows you to specify an array containing a list of all the available values. The makeChange() function takes the following parameters.
The makeChange function does assume that you have previously defined the following format method to take the calculated amounts and convert them to use the appropriate currency symbol and decimals:
You can use this with whatever code that you like that provides the original amount that is to be converted into a list of notes and coins. Just to illustrate how this works the following form simply allows you to enter an amount and the makechange function will be run when you submit the form with the answer updating the sentence below the form.
One way to make change for this amount is press button to find out.
This article written by Stephen Chapman, Felgall Pty Ltd.