Advertisement
sandunfx

Untitled

May 9th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         payout = [3, 0, 2, 0, 0];
  2.  
  3.         var status = calChange(2600, payout);
  4.  
  5.         console.log(status)
  6.  
  7.         function calChange(amount, payout) {
  8.  
  9.             var notes = [1000, 500, 100, 50, 20];
  10.  
  11.             for (i = 0; i < notes.length; i++) {
  12.  
  13.                 var count = Math.floor((amount / notes[i]))
  14.  
  15.                 console.log(notes[i] + "-" + count);
  16.  
  17.                 amount = amount - count * notes[i];
  18.  
  19.                 if (count > payout[i]) {
  20.                     return false;
  21.                 }
  22.  
  23.             }
  24.  
  25.             return true;
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement