JSFiddle - React, Tailwind, and code Playground
HTML
<div id="question"></div>
<div id="next">Next</div>
JavaScript
$(document).ready(function () {
var allQuestions = [{
question: "If you were a super hero what powers would you have?",
choices: ["a", "b", "c", "d"],
correctAnswer: 0
},
{
question: "Do you have a cherished childhood teddybear?",
choices: ["e", "f", "g", "j"],
correctAnswer: 0
},
{
question: "Whats your favourite non-alcoholic drink?",
choices: ["i", "j", "k", "l"],
correctAnswer: 0
},
{
question: "Are you religious?",
choices: ["m", "n", "o", "p"],
correctAnswer: 0
}],
count = 0,
len = allQuestions.length;
$('#next').click(function () {
if (count < len - 1) {
$('#question').text(allQuestions[count].question);
count++;
} else {
$('#next').remove();
}
});
});