Guest User

Untitled

a guest
Nov 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. const interestToPayFor = (loanAmount) => {
  2. const greaterThan2000 = { endOfRange: Money('$2000.00'), interestPerDollar: Money('$0.09'), previousInterestPerDollar: Money('$0.00') };
  3. const greaterThan5000 = { endOfRange: Money('$5000.00'), interestPerDollar: Money('$0.14'), previousInterestPerDollar: Money('$0.09') };
  4. const greaterThan10000 = { endOfRange: Money('$10000.00'), interestPerDollar: Money('$0.21'), previousInterestPerDollar: Money('$0.14') };
  5. // You can move this into a configuration file so that changes
  6. // in the behavior doesn't require code changes
  7. const ranges = [greaterThan2000, greaterThan5000, greaterThan10000];
  8. let interestAmount = Money('$0.00');
  9. for (range of ranges) {
  10. if (loanAmount.greaterThan(range.endOfRange)) {
  11. interestAmount = interestAmount.plus(calculateInterest(loanAmount, range));
  12. }
  13. }
  14. return interestAmount;
  15. };
Add Comment
Please, Sign In to add comment