Readplace

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

GitHub 1 min read
View original
  • current

This article is too short to summarise.

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

77

assert.strictEqual(actual, expected);

88

}

9910-

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');

40404141

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

);

44444545

return interestAmount;

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

4949

let interestAmount = Money('$0.00');

50505151

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');

63636464

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)