Readplace

:hammer: Remove all Magic Numbers · FagnerMartinsBrack/jack-the-moneylender@d0de7c4

GitHub 1 min read
View original
  • current

This article is too short to summarise.

Original file line numberDiff line numberDiff line change

@@ -7,10 +7,13 @@

77

}

88
99

const interestToPayForDollars = (loanAmount) => {

10-

if (loanAmount >= 2001) {

11-

return 0.09 * (loanAmount - 2000);

10+

const END_OF_FIRST_RANGE = 2000;

11+

const CENTS_FOR_FIRST_RANGE = 0;

12+

const CENTS_FOR_SECOND_RANGE = 0.09;

13+

if (loanAmount > END_OF_FIRST_RANGE) {

14+

return CENTS_FOR_SECOND_RANGE * (loanAmount - END_OF_FIRST_RANGE);

1215

}

13-

return 0;

16+

return CENTS_FOR_FIRST_RANGE;

1417

};

1518
1619

QUnit.module('$1 - $2000 = No Interest');