Created
November 28, 2017 18:05
-
-
Save jearle/2eccfc7546e75d7c099aa44bafe7223c to your computer and use it in GitHub Desktop.
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
const calculateInterest = ({ | |
initialAmount = 0, | |
additionalPerYear = 0, | |
interestRate = 0, | |
years = 0, | |
} = {}) => { | |
const annuityDue = interestRate / (interestRate + 1) | |
const x = (initialAmount + (additionalPerYear / annuityDue)) | |
const y = Math.pow(1 + interestRate, years) | |
const z = additionalPerYear / annuityDue | |
return ((x * y) - z) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment