Changed around line 1
+ // Menu Toggle
+ const menuToggle = document.querySelector('.menu-toggle');
+ const navLinks = document.querySelector('.nav-links');
+
+ menuToggle?.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ });
+
+ // Calculator Functions
+ function calculateLoanEMI(principal, rate, tenure) {
+ const monthlyRate = rate / 1200;
+ const months = tenure * 12;
+ const emi = principal * monthlyRate * Math.pow(1 + monthlyRate, months) / (Math.pow(1 + monthlyRate, months) - 1);
+ return emi;
+ }
+
+ // Input Range Handlers
+ document.querySelectorAll('input[type="range"]').forEach(input => {
+ const output = input.nextElementSibling;
+
+ input.addEventListener('input', () => {
+ output.textContent = input.value;
+ updateCalculations();
+ });
+ });
+
+ function updateCalculations() {
+ const loanAmount = parseFloat(document.getElementById('loan-amount').value);
+ const interestRate = parseFloat(document.getElementById('loan-interest').value);
+ const tenure = parseFloat(document.getElementById('loan-tenure').value);
+
+ if (loanAmount && interestRate && tenure) {
+ const emi = calculateLoanEMI(loanAmount, interestRate, tenure);
+ const totalAmount = emi * tenure * 12;
+ const totalInterest = totalAmount - loanAmount;
+
+ document.getElementById('emi-result').textContent = `$${emi.toFixed(2)}`;
+ document.getElementById('interest-result').textContent = `$${totalInterest.toFixed(2)}`;
+ updateChart(loanAmount, totalInterest);
+ }
+ }
+
+ // Chart Implementation
+ function updateChart(principal, interest) {
+ const ctx = document.getElementById('loan-chart').getContext('2d');
+
+ // Clear previous chart
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+
+ // Draw new chart (simple pie chart)
+ const total = principal + interest;
+ const principalAngle = (principal / total) * Math.PI * 2;
+
+ ctx.beginPath();
+ ctx.arc(100, 100, 50, 0, Math.PI * 2);
+ ctx.fillStyle = '#2563eb';
+ ctx.fill();
+
+ ctx.beginPath();
+ ctx.arc(100, 100, 50, 0, principalAngle);
+ ctx.fillStyle = '#22c55e';
+ ctx.fill();
+ }
+
+ // Initialize calculations
+ document.addEventListener('DOMContentLoaded', updateCalculations);