Created
November 22, 2018 10:44
-
-
Save FagnerMartinsBrack/7a685f6166adc7c8c6e552cc4c2d6d11 to your computer and use it in GitHub Desktop.
(Medium) - How TDD Can Prevent Over-Engineering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let interestAmount = Money('$0.00'); | |
- if (loanAmount.greaterThan(ranges[0].endOfRange)) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[0])); | |
- } | |
- | |
- if (loanAmount.greaterThan(ranges[1].endOfRange)) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[1])); | |
- } | |
- | |
- if (loanAmount.greaterThan(ranges[2].endOfRange)) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[2])); | |
+ for (let i = 0; i < ranges.length; i += 1) { | |
+ if (loanAmount.greaterThan(ranges[i].endOfRange)) { | |
+ interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[i])); | |
+ } | |
} | |
return interestAmount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment