function calculateROI() {
// Get Inputs
var price = parseFloat(document.getElementById('purchasePrice').value);
var closing = parseFloat(document.getElementById('closingCosts').value);
var downPmt = parseFloat(document.getElementById('downPayment').value);
var rate = parseFloat(document.getElementById('interestRate').value);
var years = parseFloat(document.getElementById('loanTerm').value);
var rent = parseFloat(document.getElementById('monthlyRent').value);
var expenses = parseFloat(document.getElementById('monthlyExpenses').value);
var vacancy = parseFloat(document.getElementById('vacancyRate').value);
// Validation
if (isNaN(price) || isNaN(downPmt) || isNaN(rate) || isNaN(years) || isNaN(rent) || isNaN(expenses)) {
alert("Please fill in all required fields with valid numbers.");
return;
}
// Default vacancy and closing if empty
if (isNaN(vacancy)) vacancy = 0;
if (isNaN(closing)) closing = 0;
// 1. Mortgage Calculation
var loanAmount = price – downPmt;
var monthlyRate = rate / 100 / 12;
var numPayments = years * 12;
var monthlyMortgage = 0;
if (rate > 0) {
monthlyMortgage = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, numPayments)) / (Math.pow(1 + monthlyRate, numPayments) – 1);
} else {
monthlyMortgage = loanAmount / numPayments;
}
// 2. Annual Income Calculations
var grossAnnualRent = rent * 12;
var vacancyLoss = grossAnnualRent * (vacancy / 100);
var effectiveGrossIncome = grossAnnualRent – vacancyLoss;
// 3. Expenses
var annualOperatingExpenses = expenses * 12;
var noi = effectiveGrossIncome – annualOperatingExpenses; // Net Operating Income
// 4. Debt Service & Cash Flow
var annualDebtService = monthlyMortgage * 12;
var annualCashFlow = noi – annualDebtService;
// 5. Returns
var totalInvestment = downPmt + closing;
var cashOnCashReturn = 0;
if (totalInvestment > 0) {
cashOnCashReturn = (annualCashFlow / totalInvestment) * 100;
}
var capRate = 0;
if (price > 0) {
capRate = (noi / price) * 100;
}
// Formatting
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
});
// Display Results
document.getElementById('annualCashFlow').innerText = formatter.format(annualCashFlow);
document.getElementById('annualCashFlow').style.color = annualCashFlow >= 0 ? '#27ae60' : '#c0392b';
document.getElementById('cashOnCash').innerText = cashOnCashReturn.toFixed(2) + "%";
document.getElementById('cashOnCash').style.color = cashOnCashReturn >= 0 ? '#27ae60' : '#c0392b';
document.getElementById('capRate').innerText = capRate.toFixed(2) + "%";
document.getElementById('monthlyMortgage').innerText = formatter.format(monthlyMortgage);
document.getElementById('annualNOI').innerText = formatter.format(noi);
document.getElementById('roiResult').style.display = 'block';
}
Understanding Rental Property ROI
Calculating the Return on Investment (ROI) for a rental property is essential for real estate investors to evaluate the profitability of a potential purchase. Unlike simple stock investments, real estate involves multiple variables including mortgage debt, operating expenses, and rental income.
Key Metrics Explained
1. Cash Flow
Cash flow is the net amount of cash moving in and out of a business. In real estate, it is calculated as Income – Expenses – Debt Service. Positive cash flow indicates that the property is generating profit month-over-month, while negative cash flow means you are losing money to hold the property.
2. Cash on Cash Return
This is arguably the most important metric for investors using leverage (mortgages). It measures the annual pre-tax cash flow relative to the total amount of cash actually invested (Down Payment + Closing Costs).
Formula: (Annual Cash Flow / Total Cash Invested) × 100
A Cash on Cash return of 8-12% is generally considered solid for long-term rentals, though this varies by market.
3. Cap Rate (Capitalization Rate)
The Cap Rate measures the natural rate of return of the property assuming it was bought with cash (no loan). It allows investors to compare properties without considering the financing structure.
Formula: (Net Operating Income / Purchase Price) × 100
How to Use This Calculator
Purchase Price & Down Payment: Enter the agreed price and how much cash you are putting down. This determines your loan amount.
Monthly Expenses: Be realistic. Include property taxes, landlord insurance, HOA fees, garbage, water, and a budget for repairs/maintenance (typically 5-10% of rent).
Vacancy Rate: No property is occupied 100% of the time. A standard conservative estimate is 5-8% (about 2-3 weeks per year).
By adjusting the rental income and expense variables, you can determine the maximum purchase price you should offer to hit your target ROI.