1 //Quizzer 2 let q1 = { 3 question: "What planet has humans?", 4 answer: "Earth" 5 }; 6 let q2 = { 7 question: "What is 13 times 3?", 8 answer: "39" 9 }; 10 let q3 = { 11 question: "Who was the first President?", 12 answer: "George Washington" 13 }; 14 let q4 = { 15 question: "What has an orbit of 27 days?", 16 answer: "moon" 17 }; 18 let q5 = { 19 question: "True or false. You’re learning JavaScript.", 20 answer: "true" 21 }; 22 let questions = [q1, q2, q3, q4, q5]; 23 let score = 0; 24 let numQuestions = questions.length; 25 for (let i = 0; i < numQuestions; i++) 26 { 27 28 let index = Math.floor(Math.random() * questions.length); 29 let pickedQuestion = questions[index]; 30 questions.splice(index, 1); 31 let playerAnswer = prompt(pickedQuestion.question); 32 if (playerAnswer === pickedQuestion.answer) 33 { 34 alert("Correct!"); 35 score++; 36 } 37 else 38 { 39 alert("No, the answer was " + pickedQuestion.answer); 40 } 41 } 42 43 let percent = score / numQuestions * 100; 44 alert("Score: " + score + " Max: " + numQuestions + 45 " Percent Correct: " + percent + "%"); 46 if (percent > 65) 47 { 48 alert("Nice work!"); 49 } 50 else 51 { 52 alert("Keep trying!"); 53 } 54