Test with questions and answer options in object in JavaScript
Let now questions, answer options and numbers of correct answers are stored in one object:
let questions = [
{
text: 'question 1?',
right: 0,
variants: [
'variant 1',
'variant 2',
'variant 3'
]
},
{
text: 'question 2?',
right: 1,
variants: [
'variant 1',
'variant 2',
'variant 3'
]
},
{
text: 'question 3?',
right: 2,
variants: [
'variant 1',
'variant 2',
'variant 3'
]
},
];
Our HTML code will be shortened to the following:
<div id="test"></div>
<button id="button">check answers</button>
Now, upon entering the page, you will have to loop through our object and form the HTML code of the questions.
Implement the assigned task.