PageSourceSearch

https://www.mybrb.bank/custom/fed-library/production/calc-builder-v2/js/calc-cd.js

js mybrb.bank collected 2026-10-09 04:39:09 UTC 1,755 bytes, 47 lines download raw bytes

1var formatter = new Intl.NumberFormat('en-US', {
2    style: 'currency',
3    currency: 'USD'
4  });
5
6var compoundInterest = function(p, t, r, n) {
7    var amount = p * (Math.pow((1 + (r / n)), (n * t)));
8    var interest = amount - p;
9    return interest;
10};
11
12var cd_form = document.getElementById('cd-form');
13var cd_elements = cd_form.elements;
14
15var cd_maturity = document.getElementById('maturity');
16var cd_interestEarned = document.getElementById('cdInterestEarned');
17var cd_apy = document.getElementById('cdApy');
18
19var cd = {
20    viewChanged: function() {
21        principal = cd_elements.initDeposit.value ? parseFloat(cd_elements.initDeposit.value) : 0;
22        termInMonths = cd_elements.termInMonths.value ? parseFloat(cd_elements.termInMonths.value) : 0;
23        cdRate = cd_elements.cdRate.value ? parseFloat(cd_elements.cdRate.value) : 0;
24        compoundFreq = cd_elements.compounded.value ? parseFloat(cd_elements.compounded.value) : 0;
25    
26        cd.updateResult(principal, termInMonths, cdRate, compoundFreq);
27    },
28
29    updateResult: function(principal, termInMonths, cdRate, compoundFreq) {
30
31        cdRate = cdRate / 100;
32        var numYears = termInMonths / 12;
33        
34        var interestEarned = compoundInterest(principal, numYears, cdRate, compoundFreq);
35
36        var futureValue = principal + interestEarned;
37        var interestEarned = futureValue - principal;
38        
39        var apy = (Math.pow(1 + cdRate / compoundFreq, compoundFreq) - 1) * 100;
40
41    
42        cd_maturity.textContent = formatter.format(futureValue);
43        cd_interestEarned.textContent = formatter.format(interestEarned);
44        cd_apy.textContent = apy.toLocaleString("en-US", { maximumFractionDigits: 3, minimumFractionDigits: 3 })+"%";
45    
46    }
47}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.