Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- payout = [3, 0, 2, 0, 0];
- var status = calChange(2600, payout);
- console.log(status)
- function calChange(amount, payout) {
- var notes = [1000, 500, 100, 50, 20];
- for (i = 0; i < notes.length; i++) {
- var count = Math.floor((amount / notes[i]))
- console.log(notes[i] + "-" + count);
- amount = amount - count * notes[i];
- if (count > payout[i]) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement