Apartment vs. House Cost-Benefit Analyzer

Cost Comparison

Apartment House
Rent/Mortgage $1,200 $1,800
Utilities $150 $250
Taxes & Insurance $0 $300
Maintenance $20 $100
Total Monthly $1,370 $2,450

Summary Report

Lifestyle Fit: House offers more space and stability for families.

"; } else { lifestyleText = "

Lifestyle Fit: Apartment suits smaller households or short-term plans.

"; } document.getElementById("lifestyleFit").innerHTML = lifestyleText; // Recommendation let recommendationDiv = document.getElementById("recommendation"); if (monthlyBudget >= totalHouse) { recommendationDiv.className = "recommendation house-recommend"; recommendationDiv.textContent = "Based on your budget and needs, a house may be suitable."; } else if (monthlyBudget >= totalApartment) { recommendationDiv.className = "recommendation apartment-recommend"; recommendationDiv.textContent = "An apartment fits better within your budget and lifestyle."; } else { recommendationDiv.className = "recommendation"; recommendationDiv.textContent = "Both options exceed your current budget. Consider adjusting expectations or increasing budget."; } // Populate PDF content const pdfContent = `

Location Preference: ${location}

Housing Interest: ${housingInterest}

Budget: $${monthlyBudget}

Occupants: ${occupants}

Monthly Costs:

  • Apartment: $${totalApartment}
  • House: $${totalHouse}

Recommendation: ${recommendationDiv.textContent}

`; document.getElementById("pdfContent").innerHTML = pdfContent; }; // Load jsPDF dynamically const script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js'; document.head.appendChild(script); window.generatePDF = function() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); const lines = [ "Apartment vs. House Cost-Benefit Analysis", "", `Location Preference: ${document.getElementById("location").value}`, `Housing Interest: ${document.getElementById("housingType").value}`, `Monthly Budget: $${document.getElementById("monthlyBudget").value}`, `Recommended Apartment Cost: $${document.getElementById("totalApartment").innerText.replace('$','')}`, `Recommended House Cost: $${document.getElementById("totalHouse").innerText.replace('$','')}`, `Recommendation: ${document.getElementById("recommendation").textContent}`, ]; doc.setFontSize(14); lines.forEach((line, i) => { doc.text(line, 10, 20 + i * 10); }); doc.save("housing_comparison.pdf"); }; });
Scroll to Top