I wrote a program which asks the user a series of questions and determines whether the answer entered by the user is correct or incorrect. Example:
var questionsCorrect = 0
var question1 = prompt("question 1");
if (question1.toLowerCase() === "answer 1") {
question1 = true;
questionsCorrect += 1;
alert("Correct");
} else {
question1 = false;
alert("Incorrect");
}
var question2 = prompt("question 2");
if (question2.toLowerCase() === "answer 2") {
question2 = true;
questionsCorrect += 1;
alert("Correct");
} else {
question2 = false;
alert("Incorrect");
}
...
I plan on displaying how many questions the user answered correctly after all of the questions are asked. Suppose the code goes on this way until question10. how would I use the Math.random() function so that the questions are asked in random order?