Real-Time Portfolio Challenge Game
Performance Change: ${change}%
New Balance: $${parseFloat(newBalance).toLocaleString()}
`; document.getElementById('gameOutput').innerHTML = content; } window.downloadGamePDF = function () { const output = document.getElementById('gameOutput'); const button = document.getElementById('downloadPDF'); if (!output.innerHTML.trim()) { alert("Please simulate the portfolio before downloading the PDF."); return; } button.style.display = 'none'; html2canvas(output).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF(); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 10, pdfWidth, pdfHeight); pdf.save("Portfolio_Challenge_Result.pdf"); button.style.display = 'inline-block'; }); } });