I borrowed a quiz's code from this site https://www.sitepoint.com/simple-javascript-quiz/ the thing is, I'm trying to get the questions to be displayed in a random order in the screen, rather than in the same order everytime. I've tried multiple ways but none seem to work, so help would be greatly appreciated. I'm guessing the solution lays in this function, but I'm not entirely sure what to modify.
function buildQuiz() {
// we'll need a place to store the HTML output
const output = [];
// for each question...
myQuestions.forEach((currentQuestion, questionNumber) => {
// we'll want to store the list of answer choices
const answers = [];
// and for each available answer...
for (letter in currentQuestion.answers) {
// ...add an HTML radio button
answers.push(
`<label>
<input type="radio" name="question${questionNumber}" value="${letter}" id="botones">
${letter} :
${currentQuestion.answers[letter]}
</label>`
);
}
// add this question and its answers to the output
output.push(
`<div class="slide">
<div class="question"> ${currentQuestion.question} </div>
<div class="answers"> ${answers.join("")} </div>
</div>`
);
});
// finally combine our output list into one string of HTML and put it on the page quizContainer.innerHTML = output.join(""); }