diff --git a/assets/js/assessment_old.js b/assets/js/assessment_old.js deleted file mode 100644 index 59149b6..0000000 --- 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);