From 38728dd42f734ce2e0dddeaa89684c25c8e0e2a3 Mon Sep 17 00:00:00 2001 From: shraddha <224512+shraddha@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:59:58 +0530 Subject: [PATCH] accidentally added the file deleting the file from the code --- assets/js/assessment_old.js | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 assets/js/assessment_old.js diff --git a/assets/js/assessment_old.js b/assets/js/assessment_old.js deleted file mode 100644 index 59149b66..00000000 --- a/assets/js/assessment_old.js +++ /dev/null @@ -1,40 +0,0 @@ -const quizContainer = document.getElementById("quiz"); -const resultsContainer = document.getElementById("results"); -const submitButton = document.getElementById("submit"); - - -function showResults() { - // gather answer containers from our quiz - const answerContainers = quizContainer.querySelectorAll(".answers"); - answerContainers.forEach(e => e.style.color = "black"); - - // keep track of user's answers - let numCorrect = 0; - - // for each question... - myQuestions.forEach((currentQuestion, questionNumber) => { - // find selected answer - const answerContainer = answerContainers[questionNumber]; - const selector = `input[name=question${questionNumber}]:checked`; - const userAnswer = (answerContainer.querySelector(selector) || {}).value; - - // if answer is correct - if (userAnswer === currentQuestion.correctAnswer) { - // add to the number of correct answers - numCorrect++; - - // color the answers green - //answerContainers[questionNumber].style.color = "lightgreen"; - } else { - // if answer is wrong or blank - // color the answers red - answerContainers[questionNumber].style.color = "red"; - } - }); - - // show number of correct answers out of total - resultsContainer.innerHTML = `${numCorrect} out of ${myQuestions.length}`; -} - - -submitButton.addEventListener("click", showResults);