Created
March 28, 2012 23:52
-
-
Save jacobsimeon/2231615 to your computer and use it in GitHub Desktop.
Mortgage_calculator
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
var calculate_payment = function(loan_amount, interest_rate){ | |
var _rate = interest_rate / 1200; | |
var pi = ( _rate + (_rate / (Math.pow((1 + _rate), 360) - 1) ) ) * loan_amount; | |
var taxes = (loan_amount * 0.01) / 12; | |
var ins = 40; | |
var mi = (loan_amount * 0.0125) / 12; | |
return pi + taxes + ins + mi; | |
} | |
for(var i = 120; i <= 160; i++){ | |
console.log( i * 1000, calculate_payment(i * 1000, 3.85) ) | |
} | |
/* | |
120000 827.5698786882266 | |
121000 834.1329610106284 | |
122000 840.6960433330303 | |
123000 847.2591256554322 | |
124000 853.8222079778341 | |
125000 860.385290300236 | |
126000 866.9483726226379 | |
127000 873.5114549450398 | |
128000 880.0745372674417 | |
129000 886.6376195898436 | |
130000 893.2007019122454 | |
131000 899.7637842346473 | |
132000 906.3268665570492 | |
133000 912.889948879451 | |
134000 919.4530312018529 | |
135000 926.0161135242548 | |
136000 932.5791958466567 | |
137000 939.1422781690586 | |
138000 945.7053604914605 | |
139000 952.2684428138624 | |
140000 958.8315251362643 | |
141000 965.3946074586662 | |
142000 971.9576897810681 | |
143000 978.52077210347 | |
144000 985.0838544258719 | |
145000 991.6469367482738 | |
146000 998.2100190706756 | |
147000 1004.7731013930775 | |
148000 1011.3361837154794 | |
149000 1017.8992660378813 | |
150000 1024.4623483602832 | |
151000 1031.025430682685 | |
152000 1037.588513005087 | |
153000 1044.1515953274888 | |
154000 1050.7146776498907 | |
155000 1057.2777599722926 | |
156000 1063.8408422946945 | |
157000 1070.4039246170964 | |
158000 1076.9670069394983 | |
159000 1083.5300892619002 | |
160000 1090.0931715843021 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment