Created
April 13, 2025 15:59
-
-
Save davidystephenson/78c58a858135911e6f8cf25642666186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let currentQuestion = 0 | |
let score = 0 | |
const numOfQuestions = questions.length | |
const numOfChoices = 3 | |
const questionCountElement = document.getElementById('question-count') | |
function displayQuestion () { | |
const question = questions[currentQuestion] | |
console.log('question', question) | |
const questionElement = document.getElementById('question') | |
questionElement.innerText = question.question | |
const countMessage = `${currentQuestion + 1}/${numOfQuestions}` | |
questionCountElement.innerText = countMessage | |
const choices = document.getElementsByClassName('choice') | |
console.log('choices', choices) | |
// choices[0].innerText = question.choices[0] | |
// choices[1].innerText = question.choices[1] | |
// choices[2].innerText = question.choices[2] | |
const choicesArray = [...choices] | |
choicesArray.forEach((choice, index) => { | |
choice.innerText = question.choices[index] | |
}) | |
} | |
displayQuestion() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment