Creating Random Questions And Answers Javascript
I have a question and answer section of my site, where the user is asked 6 questions of out 40 possible questions. There are set answers for each one, but there isn't a correct ans
Solution 1:
Step 1) Declare a questions table:
var questions = [1, 2, 3, 4, 5, ..., 40];
Step 2) Get the 1st random question
var random1 = Math.floor(Math.random() * questions.length) ;
var choice1 = questions[random1];
Step 3) Remove it from the table
questions.splice(random1, 1);
Repeat steps 2 & 3 to get more questions
Post a Comment for "Creating Random Questions And Answers Javascript"