JavaScript JavaScript Arrays Multidimensional Arrays Improve the Quiz – One Solution

Another solution. Is it ok?

I used the already created for loop and just built the html text in 2 variables for right and wrong answers instead of creating 2 new arrays. I also didn't use the function. Any issues with this? Effeciency?

const quiz = [ 
  ['How many primary colors are there?', '6'], 
  ['What is the opposite of right', 'left'],
  ['If you are not up, you are?', 'down']          
];

let rightAnswers = '';
let wrongAnswers = '';
let correct = 0;

for (let i = 0; i < quiz.length; i++ ) {
  let answer = prompt(quiz[i][0]);
  if (answer.toLowerCase() === quiz[i][1].toLowerCase()) {
    correct += 1;
    rightAnswers += `<li>${quiz[i][0]}</li>`;
  } else {
    wrongAnswers += `<li>${quiz[i][0]}</li>`;
  }
}

let html = `<h1>Total correct answers is ${correct}</h1><p>You answered these questions correct:</p>
<ol>${rightAnswers}</ol> <p>You answered these questions wrong: </p><ol>${wrongAnswers}</ol>`;

document.querySelector('main').innerHTML = html

I did it same way as you did, found it to be less complex version. And I didn't declare the html variable, just placed it directly in document.querySelector.

I wrote the code exactly like you did, so hopefully it's ok, lol.