This calculator helps you estimate how much you might need to save for retirement and how long it might take to reach your goal. Enter your current savings, expected annual contributions, desired retirement income, and your expected rate of return.
";
outputHTML += "Your desired annual retirement income of $" + desiredRetirementIncome.toLocaleString() +
" with a safe withdrawal rate of " + (withdrawalRate * 100).toFixed(1) + "% requires a nest egg of $" + retirementNestEggNeeded.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ".";
outputHTML += "Projected total savings at retirement: $" + totalProjectedSavings.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ".";
if (shortfallOrSurplus >= 0) {
outputHTML += "Congratulations! You are projected to have a surplus of $" + shortfallOrSurplus.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + " at retirement.";
} else {
outputHTML += "You are projected to have a shortfall of $" + Math.abs(shortfallOrSurplus).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + " at retirement. You may need to increase contributions, work longer, or adjust your retirement income goals.";
}
resultElement.innerHTML = outputHTML;
}