document.addEventListener('DOMContentLoaded', function() {
let score = 0;
const totalQuestions = 5; // Replace with your total number of questions if infutre you add new questions in quiz
// Correct button IDs (legitimate answers)
const correctButtons = ['p1', 'p2', 'l3', 'p4', 'p5']; // Replace with the correct buttons
correctButtons.forEach(buttonId => {
const button = document.getElementById(buttonId);
if (button) {
button.addEventListener('click', function() {
score++;
localStorage.setItem('quizScore', score); // Store the score in local storage
});
}
});
// Incorrect buttons do not affect the score but should ensure the score is stored
const incorrectButtons = ['l1', 'l2', 'p3', 'l4', 'l5']; // Replace with the incorrect buttons
incorrectButtons.forEach(buttonId => {
const button = document.getElementById(buttonId);
if (button) {
button.addEventListener('click', function() {
localStorage.setItem('quizScore', score); // Ensure score is stored
});
}
});
});