function calculateCashOnCash() {
// 1. Get Input Values
var price = parseFloat(document.getElementById('purchasePrice').value);
var downPercent = parseFloat(document.getElementById('downPaymentPercent').value);
var interestRate = parseFloat(document.getElementById('interestRate').value);
var loanTerm = parseFloat(document.getElementById('loanTerm').value);
var closingCosts = parseFloat(document.getElementById('closingCosts').value);
var rehabCosts = parseFloat(document.getElementById('rehabCosts').value);
var monthlyRent = parseFloat(document.getElementById('monthlyRent').value);
var annualTaxes = parseFloat(document.getElementById('annualTaxes').value);
var annualInsurance = parseFloat(document.getElementById('annualInsurance').value);
var monthlyHOA = parseFloat(document.getElementById('monthlyHOA').value);
var errorDiv = document.getElementById('errorMsg');
var resultsDiv = document.getElementById('roiResults');
// 2. Validation
// Check if required fields are NaN (allow rehab/hoa to be 0 if user enters 0, but must be parsed)
if (isNaN(price) || isNaN(downPercent) || isNaN(interestRate) || isNaN(loanTerm) ||
isNaN(monthlyRent) || isNaN(annualTaxes) || isNaN(annualInsurance)) {
errorDiv.style.display = 'block';
resultsDiv.style.display = 'none';
return;
}
// Default optional fields to 0 if empty/NaN but valid otherwise
if (isNaN(closingCosts)) closingCosts = 0;
if (isNaN(rehabCosts)) rehabCosts = 0;
if (isNaN(monthlyHOA)) monthlyHOA = 0;
errorDiv.style.display = 'none';
// 3. Calculations
// A. Loan and Investment
var downPaymentAmount = price * (downPercent / 100);
var loanAmount = price – downPaymentAmount;
var totalCashInvested = downPaymentAmount + closingCosts + rehabCosts;
// B. Mortgage Calculation (M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1 ])
var monthlyRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
var monthlyMortgage = 0;
if (monthlyRate > 0) {
monthlyMortgage = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments)) / (Math.pow(1 + monthlyRate, numberOfPayments) – 1);
} else {
monthlyMortgage = loanAmount / numberOfPayments;
}
// C. Expenses
var monthlyTax = annualTaxes / 12;
var monthlyInsurance = annualInsurance / 12;
var totalMonthlyExpenses = monthlyMortgage + monthlyTax + monthlyInsurance + monthlyHOA;
// D. Cash Flow
var monthlyCashFlow = monthlyRent – totalMonthlyExpenses;
var annualCashFlow = monthlyCashFlow * 12;
// E. Cash on Cash Return
var cocReturn = 0;
if (totalCashInvested > 0) {
cocReturn = (annualCashFlow / totalCashInvested) * 100;
}
// 4. Update UI
document.getElementById('resTotalInvested').innerText = '$' + totalCashInvested.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('resMortgage').innerText = '$' + monthlyMortgage.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('resTotalExpenses').innerText = '$' + totalMonthlyExpenses.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
var monthlyFlowEl = document.getElementById('resMonthlyCashFlow');
monthlyFlowEl.innerText = '$' + monthlyCashFlow.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
monthlyFlowEl.style.color = monthlyCashFlow >= 0 ? '#27ae60' : '#c0392b';
var annualFlowEl = document.getElementById('resAnnualCashFlow');
annualFlowEl.innerText = '$' + annualCashFlow.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
annualFlowEl.style.color = annualCashFlow >= 0 ? '#27ae60' : '#c0392b';
var cocEl = document.getElementById('resCoC');
cocEl.innerText = cocReturn.toFixed(2) + '%';
cocEl.style.color = cocReturn >= 0 ? '#27ae60' : '#c0392b';
resultsDiv.style.display = 'block';
}
Understanding Cash on Cash Return for Rental Properties
Investing in real estate is one of the most reliable ways to build wealth, but not all properties are good investments. The Cash on Cash Return (CoC) metric is arguably the most important calculation for rental property investors because it measures the efficiency of the cash you actually invested, rather than the total value of the property.
How is Cash on Cash Return Calculated?
Unlike a standard Cap Rate calculation, which looks at the property's unleveraged yield, Cash on Cash Return takes into account your financing (mortgage). The formula is:
Cash on Cash Return = (Annual Pre-Tax Cash Flow / Total Cash Invested) × 100
Total Cash Invested includes your down payment, closing costs, and any immediate repair or rehabilitation costs required to get the property rent-ready.
Why Use This Calculator?
This calculator helps you perform a "deal analysis" in seconds. By inputting your acquisition costs and operating expenses, you can immediately see if a property generates positive cash flow.
Analyze Leverage: See how changing your down payment percentage affects your return.
Expense Tracking: Account for "silent killers" of profit like Vacancy, Maintenance, and HOA fees (grouped in the calculator under monthly maintenance).
Make Better Offers: If the ROI isn't high enough at the asking price, adjust the Purchase Price field to find the maximum offer you should make.
What is a Good Cash on Cash Return?
"Good" is subjective, but generally speaking:
8-12%: Considered a solid return in most stable markets.
15%+: Excellent returns, often found in riskier markets or properties requiring significant work (BRRRR strategy).
Under 5%: Often considered poor for a pure cash-flow play, unless the property is in a high-appreciation market (like San Francisco or NYC).
Example Calculation
Imagine you buy a property for $200,000. You put 20% down ($40,000) and pay $5,000 in closing costs. Your total cash invested is $45,000.
After paying the mortgage, taxes, insurance, and maintenance, your property nets $300 per month in pure profit.
Annual Cash Flow = $300 × 12 = $3,600
Total Cash Invested = $45,000
ROI = ($3,600 / $45,000) = 8%
Use the calculator above to run your own numbers and ensure your next rental property is a profitable asset, not a liability.