0

(I haven't decided what exactly the questions and options are going to be yet). You can see below the parse object I've tried to build the quiz using form. When I try to run this code nothing shows up. What am I doing wrong? I really, really appreciate any help.

const json = 
  { quiz: 
    { q1: { question: 'The question?', options: [ 'option one', 'option two'] , answer: 'The answer' } 
    , q2: { question: 'The question?', options: [ 'option one', 'option two'] , answer: 'The answer' } 
    , q3: { question: 'The question?', options: [ 'option one', 'option two'] , answer: 'The answer' } 
    , q4: { question: 'The question?', options: [ 'option one', 'option two'] , answer: 'The answer' } 
  } } 
  
var obj = JSON.parse(JSON.stringify(json));
console.log(obj);

for (let i = 0; i < obj.quiz.length; i++) {
  document.body.innerHTML +=
    '<h2>' + obj.quiz[i].question + '</h2>'
  document.body.innerHTML +=
    '<form>' + '<input type="radio" name="options" value="option">' + '<label for="option">' + obj.quiz[i].options + '</label>' + '<br>' + '</form>'
}
Mister Jojo
  • 20,093
  • 6
  • 21
  • 40

0 Answers0