Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Arrays Multidimensional Arrays Build a Quiz Challenge – One Solution

Build a Quiz 1 Solution

const qATest = [
  ['What color is the moon?', 'white'],
  ['What year was Javascript born?', '1995'],
  ['What is the name of the crypto sock business?', 'sockhodler'],
  ['Will I ever become a true programmer?', 'yes']

let answerCorrect = 0;

for ( let i = 0; i < qATest.length; i++ ){
  const questions = prompt(qATest[i][0]);
  if (questions.toLowerCase() === qATest[i][1]) {

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

<h1>You got ${answerCorrect} question(s) correct</h1>


Please let me know if anyone has any feedback on how to improve my code at this point.

1 Answer

Steven Parker
Steven Parker
218,596 Points

Looks good so far. As shown later in the video, the instructor uses arrays and a function to make the code a bit more compact, but that's only a slight improvement and not necessary at all to meet the stated objectives.

Good job!   :+1: