Online AI-Based Mental Math Trainer

AI-Based Mental Math Trainer

Sharpen your mind with a custom math challenge.

00:00

Training Complete!

AI Tutor Feedback:

${aiFeedback.textContent}

Problem Breakdown

${tableRows}
#ProblemCorrect AnswerYour AnswerResult
`; pdfContentArea.style.display = 'block'; pdfContentArea.style.position = 'absolute'; pdfContentArea.style.left = '-9999px'; pdfContentArea.style.width = '800px'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgHeight = canvas.height * pdfWidth / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight); pdf.save(`Mental-Math-Report.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("Could not generate PDF."); } finally { pdfContentArea.style.display = 'none'; } } // --- Event Listeners --- startBtn.addEventListener('click', startTraining); answerInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') checkAnswer(); }); downloadResultsBtn.addEventListener('click', generatePdf); startOverBtn.addEventListener('click', () => switchView('setup')); // --- Initial State --- switchView('setup'); });
Scroll to Top