`; message += `
Current Card Balance: ${format(totalOldBalance)}
Card Balance + Transfer Fee: ${format(totalNewBalance)}
`; message += `
Current Interest Rate (median): ${medianOldInterestRate.toFixed(2)}%
New Interest Rate: ${newInterestRate.toFixed(2)}%
`; message += `
Current Monthly Payment: ${format(totalOldMonthlyPayment)}
New Monthly Payment: ${format(newMonthlyPayment)}
`; if (totalMonthlySavings > 0) { message += `
Total Monthly Savings: ${format(totalMonthlySavings)}
Monthly Savings (Intro Period): ${format(monthlySavingsIntroductory)}
Monthly Savings (After Intro Period): ${format(monthlySavingsAfterIntro)}
`; } else { message += `
No Savings Found: You are not saving on a monthly basis after switching cards.
`; } message += `
Months Saved by Switching: ${monthsSaved} months
`; message += `
Total Interest Paid on Current Card: ${format(totalOldInterestPaid)}
Total Interest Paid on New Card: ${format(totalInterestPaid)}
`; message += `
Final Balance on Current Card: ${format(finalOldBalance)}
Final Balance on New Card: ${format(finalBalance)}
`; message += `
Total Cost of Current Card (Balance + Interest): ${format(totalOldBalance + totalOldInterestPaid)}
Total Cost of New Card (Balance + Interest + Fees): ${format(finalBalance + totalInterestPaid + data.annualFee)}
`; if (monthsSaved > 0) { message += `
Great News: You saved ${monthsSaved} months by switching cards! This means you can pay off your debt faster.
`; } else { message += `
Heads Up: You didn't save any time by switching cards. Consider other options to reduce your debt faster.
`; } if (totalMonthlySavings > 0) { message += `
Monthly Savings: You are saving ${format(totalMonthlySavings)} every month, which could help you pay off your debt quicker.
`; } else { message += `
No Monthly Savings: The new card may not offer enough savings to offset the payments. Consider negotiating a lower rate or finding a better offer.
`; } message += `
Important: We limit our calculations to a maximum of 60 months for display purposes, so the final balance may not reflect the actual amount if it takes longer to pay off.
`; message += `
`; // Display the message document.getElementById("resultMessage").innerHTML = message;}// Helper function to format numbers to currencyfunction format(num) { return `$${parseFloat(num).toFixed(2)}`;}// Tooltip setup for mobile-friendly tooltipsdocument.querySelectorAll("input[title]").forEach((input) => { input.addEventListener("focus", () => showTooltip(input)); input.addEventListener("blur", hideTooltip);});function showTooltip(element) { const tooltip = document.createElement("div"); tooltip.className = "tooltip"; tooltip.innerText = element.getAttribute("title"); document.body.appendChild(tooltip); const rect = element.getBoundingClientRect(); tooltip.style.left = `${rect.left + window.scrollX + element.offsetWidth / 2 - tooltip.offsetWidth / 2}px`; tooltip.style.top = `${rect.top + window.scrollY - tooltip.offsetHeight - 5}px`; element.tooltipElement = tooltip;}function hideTooltip(event) { const tooltip = event.target.tooltipElement; if (tooltip) { tooltip.remove(); event.target.tooltipElement = null; }}