This file contains hidden or 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
| function format(input) { | |
| // input.value = (input.value).toLocaleString('en-US'); | |
| var nStr = input.value + ""; | |
| nStr = nStr.replace(/\,/g, ""); | |
| x = nStr.split("."); | |
| x1 = x[0]; | |
| x2 = x.length > 1 ? "." + x[1] : ""; | |
| var rgx = /(\d+)(\d{3})/; | |
| while (rgx.test(x1)) { | |
| x1 = x1.replace(rgx, "$1" + "," + "$2"); |
This file contains hidden or 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 princ = 10000; // start deposit | |
| let add = 500; // monthly deposit (need plus it every year) | |
| let rate = 0.06; // interest rate divided to create decimal | |
| let months = (41 * 12); //41 years of monthly contributions | |
| for (let i = 1; i <= months; i++) { | |
| princ += princ * (rate / 12); | |
| princ += add; | |
| console.log(princ); | |
| } |
This file contains hidden or 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
| function pmt(rate, nper, pv) { | |
| if (rate == 0) return -(pv) / nper; | |
| var pvif = Math.pow(1 + rate, nper); | |
| var PMT = rate / (pvif - 1) * -(pv * pvif); | |
| return PMT; | |
| } |
This file contains hidden or 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 RATE = function(nper, pmt, pv, fv, type, guess) { | |
| // Sets default values for missing parameters | |
| fv = typeof fv !== 'undefined' ? fv : 0; | |
| type = typeof type !== 'undefined' ? type : 0; | |
| guess = typeof guess !== 'undefined' ? guess : 0.1; | |
| // Sets the limits for possible guesses to any | |
| // number between 0% and 100% | |
| var lowLimit = 0; | |
| var highLimit = 1; |