A Certificate of Deposit (CD) is a type of savings account offered by banks and credit unions that typically offers a higher interest rate than a regular savings account. In return for the higher rate, you agree to leave your money in the CD for a fixed period, known as the term. If you withdraw your money before the term ends, you may be subject to early withdrawal penalties. Our CD Rate Calculator helps you estimate the earnings on your CD based on the principal amount, the annual interest rate, and the term length.
function calculateCDInterest() {
var principal = parseFloat(document.getElementById("principalAmount").value);
var rate = parseFloat(document.getElementById("annualInterestRate").value);
var termMonths = parseFloat(document.getElementById("termInMonths").value);
var resultDiv = document.getElementById("result");
if (isNaN(principal) || isNaN(rate) || isNaN(termMonths) || principal < 0 || rate < 0 || termMonths <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields. Term must be greater than 0.";
return;
}
var ratePerPeriod = rate / 100 / 12; // Monthly interest rate
var totalMonths = termMonths;
// Calculate future value using compound interest formula: FV = P * (1 + r)^n
// Assuming interest is compounded monthly for simplicity in this calculator
var futureValue = principal * Math.pow(1 + ratePerPeriod, totalMonths);
var totalInterestEarned = futureValue – principal;
resultDiv.innerHTML =
"