Download EPUB

:hammer: Use only one 'interest amount' variable to return · FagnerMartinsBrack/jack-the-moneylender@649a980

GitHub 1 min read Original article

This article is too short to generate a summary.

@@ -18,34 +18,24 @@

1818

const greaterThan5000 = { endOfRange: Money('$5000.00'), interestPerDollar: Money('$0.14'), previousInterestPerDollar: Money('$0.09') };

1919

const greaterThan10000 = { endOfRange: Money('$10000.00'), interestPerDollar: Money('$0.21'), previousInterestPerDollar: Money('$0.14') };

2020
21-

if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) {

22-

let interestAmount = Money('$0.00');

21+

let interestAmount = Money('$0.00');

2322
23+

if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) {

2424

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000));

25-
26-

return interestAmount;

2725

}

2826
2927

if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) {

30-

let interestAmount = Money('$0.00');

31-
3228

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000));

3329

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000));

34-
35-

return interestAmount;

3630

}

3731
3832

if (loanAmount.greaterThan(Money('$10000.00'))) {

39-

let interestAmount = Money('$0.00');

40-
4133

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000));

4234

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000));

4335

interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan10000));

44-
45-

return interestAmount;

4636

}

4737
48-

return Money('$0.00');

38+

return interestAmount;

4939

};

5040
5141

QUnit.module('Loans of $2000 and below are interest-free. For example');

Keep this one

Free to use, with no card: save new links within daily limits and read everything you save.

Every new account gets the paid plan for its first 14 days.