Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made changes in the selection and deselection of choices #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Quiz App/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ const showQuestions = () => {
choicesBox.appendChild(choiceDiv);

choiceDiv.addEventListener('click', () => {
if (choiceDiv.classList.contains('selected')) {
choiceDiv.classList.remove('selected');
}
else {
choiceDiv.classList.add('selected');
}
// Deselect all choices
const allChoices = document.querySelectorAll('.choice');
allChoices.forEach((choice) => {
choice.classList.remove('selected');
});

// Select the clicked choice
choiceDiv.classList.add('selected');
});
}

if(currentQuestionIndex < quiz.length){
if(currentQuestionIndex < quiz.length){
startTimer();
}
}
Expand Down