How to load a new set of question with the current set overlay its previous set?

Viewed 35

https://codepen.io/Maximusssssu/pen/NWNdbPq

Hi, I have created 2 set of questions which is shown in my code. I wish to show one set of questions per time in order to create a button like Question Set 1 and Question Set 2 which doesn't appear simultaneously. Is it possible to be done? Thank you.

var all_questions = [{
  question_string: "What color is the sky?",
  choices: {
    correct: "he",
    wrong: ["sink", "ge", "een"]
  }
},{
  question_string: "Whajis the sky?",
  choices: {
    correct: "Blue",
    wrong: ["Pink", "Orange", "Green"]
  }
}];
1 Answers

Why not add a counter on your program and overwrite the click function so that it saves your choice and then it will show you the second question. And after counter === questions.length -1 you can print the results.

Bonus: You can use linked lists instead of having a counter and check question.next === undefined to understand when you are at the last question. See this page to learn more about linked lists.

Related