The Capitalization Rate (Cap Rate) is a key metric used in real estate to estimate the potential return on investment for an income-generating property. It is calculated by dividing the property's Net Operating Income (NOI) by its current market value or purchase price.
function calculateCapRate() {
var noi = parseFloat(document.getElementById("netOperatingIncome").value);
var propertyValue = parseFloat(document.getElementById("propertyValue").value);
var resultDiv = document.getElementById("result");
if (isNaN(noi) || isNaN(propertyValue)) {
resultDiv.textContent = "Please enter valid numbers for both fields.";
resultDiv.style.color = "red";
return;
}
if (propertyValue <= 0) {
resultDiv.textContent = "Property Value must be greater than zero.";
resultDiv.style.color = "red";
return;
}
var capRate = (noi / propertyValue) * 100;
if (isNaN(capRate)) {
resultDiv.textContent = "Cannot calculate Cap Rate. Please check your inputs.";
resultDiv.style.color = "red";
} else {
resultDiv.textContent = "Capitalization Rate: " + capRate.toFixed(2) + "%";
resultDiv.style.color = "black";
}
}