function selectAnswer(index) { if (index === questions[currentQuestion].correct) { score++; } currentQuestion++; showQuestion(); } function startTimer() { document.getElementById('timer').textContent = timer; timerInterval = setInterval(() => { timer--; document.getElementById('timer').textContent = timer; if (timer <= 0) { clearInterval(timerInterval); endQuiz(); } }, 1000); } function endQuiz() { clearInterval(timerInterval); document.getElementById('quiz-screen').classList.add('hidden'); document.getElementById('end-screen').classList.remove('hidden'); document.getElementById('final-score').textContent = score; }