The Compound Annual Growth Rate (CAGR) is a crucial metric used to determine the average annual growth of an investment or business over a specified period, assuming that profits were reinvested at the end of each year of the investment's lifespan. CAGR is a more accurate way to represent growth than simple average growth because it takes into account the compounding effect. It smooths out volatility and provides a more representative growth rate over time.
The formula for CAGR is:
CAGR = [(Ending Value / Beginning Value) ^ (1 / Number of Years)] - 1
function calculateCAGR() {
var beginningValue = parseFloat(document.getElementById("beginningValue").value);
var endingValue = parseFloat(document.getElementById("endingValue").value);
var numberOfYears = parseFloat(document.getElementById("numberOfYears").value);
var resultDiv = document.getElementById("result");
if (isNaN(beginningValue) || isNaN(endingValue) || isNaN(numberOfYears)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (beginningValue <= 0) {
resultDiv.innerHTML = "Beginning Value must be greater than zero.";
return;
}
if (numberOfYears <= 0) {
resultDiv.innerHTML = "Number of Years must be greater than zero.";
return;
}
var cagr = Math.pow((endingValue / beginningValue), (1 / numberOfYears)) – 1;
var formattedCAGR = (cagr * 100).toFixed(2);
resultDiv.innerHTML = "