Investment Growth Calculator
function invCalc() {
var p = parseFloat(document.getElementById(‘inv-initial’).value) || 0;
var pmt = parseFloat(document.getElementById(‘inv-monthly’).value) || 0;
var r = parseFloat(document.getElementById(‘inv-rate’).value) / 100 / 12 || 0;
var n = parseInt(document.getElementById(‘inv-years’).value) * 12 || 0;
if (!n) return;
var fv = p * Math.pow(1 + r, n) + pmt * ((Math.pow(1 + r, n) – 1) / r);
var fmt = new Intl.NumberFormat(‘en-US’, {style:’currency’,currency:’USD’,maximumFractionDigits:0});
document.getElementById(‘inv-total’).textContent = fmt.format(fv);
document.getElementById(‘inv-result’).style.display = ‘block’;
}