Download EPUB

:hammer: Add the last arg for the function to calculate loans above $… · FagnerMartinsBrack/jack-the-moneylender@6fa4b94

GitHub 1 min read Original article

This article is too short to generate a summary.

@@ -7,9 +7,9 @@

77

assert.strictEqual(actual, expected);

88

}

99
10-

const calculateInterestForGreaterThan2000 = (loanAmount, endOfFirstRange, centsForSecondRange) => {

10+

const calculateInterestForGreaterThan2000 = (loanAmount, endOfFirstRange, centsForSecondRange, centsForFirstRange) => {

1111

const dollarsAboveThresholdForGreaterThan2000 = loanAmount.minus(endOfFirstRange);

12-

const interestForGreaterThan2000 = centsForSecondRange.multipliedBy(dollarsAboveThresholdForGreaterThan2000);

12+

const interestForGreaterThan2000 = centsForSecondRange.minus(centsForFirstRange).multipliedBy(dollarsAboveThresholdForGreaterThan2000);

1313

return interestForGreaterThan2000;

1414

};

1515

@@ -39,7 +39,7 @@

3939

let interestAmount = Money('$0.00');

4040
4141

interestAmount = interestAmount.plus(

42-

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)

42+

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)

4343

);

4444
4545

return interestAmount;

@@ -49,7 +49,7 @@

4949

let interestAmount = Money('$0.00');

5050
5151

interestAmount = interestAmount.plus(

52-

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)

52+

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)

5353

);

5454

interestAmount = interestAmount.plus(

5555

calculateInterestForGreaterThan5000(loanAmount, END_OF_SECOND_RANGE, CENTS_FOR_THIRD_RANGE, CENTS_FOR_SECOND_RANGE)

@@ -62,7 +62,7 @@

6262

let interestAmount = Money('$0.00');

6363
6464

interestAmount = interestAmount.plus(

65-

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)

65+

calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)

6666

);

6767

interestAmount = interestAmount.plus(

6868

calculateInterestForGreaterThan5000(loanAmount, END_OF_SECOND_RANGE, CENTS_FOR_THIRD_RANGE, CENTS_FOR_SECOND_RANGE)

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.