I have this quiz I am trying to make. I want it so it generates a random question.
I have
var quiz = [{
"question": "Question 1: Who is Megatron", // Question 1
"choices": [
"Brandon Marshall",
"Larry Fitzgerald",
"Robert Griffin III",
"Calvin Johnson"
],
"correct": "Calvin Johnson"
}, {
"question": "Question 2: Which player has won the most Superbowls", // Question 2
"choices": [
"Eli Manning",
"Peyton Manning",
"Aaron Rodgers",
"Tom Brady"
],
"correct": "Tom Brady"
}, ];
and I have
var randomNumber =Math.floor(Math.random()*3);
var currentQuestion = (randomNumber);
if(currentQuestion < quiz.length - 1){
currentQuestion(randomNumber);
questionsDone++;
loadQuestion();
} else {
showFinalResults();
}
After I freshly reload the page, the question is random. After I answer that question, a another random question doesn't appear. I want it so it generates a random number. every time I hit answer a question and use the randomly generated number as the question number.