Tell us what’s happening:
Why I can’t pass the test 11 and 13? What is my problem?
Your code so far
const questions= [
{
category: "Science",
question: "What is the chemical symbol for water?",
choices: ["H2O", "O2", "CO2"],
answer: "H2O"
},
{
category: "Geography",
question: "Which is the largest continent on Earth?",
choices: ["Africa", "Asia", "Europe"],
answer: "Asia"
},
{
category: "History",
question: "Who was the first President of the United States?",
choices: ["George Washington", "Thomas Jefferson", "Abraham Lincoln"],
answer: "George Washington"
},
{
category: "Sports",
question: "How many players are on a standard soccer team on the field?",
choices: ["9", "10", "11"],
answer: "11"
},
{
category: "Technology",
question: "What does 'HTML' stand for?",
choices: [
"Hyper Trainer Marking Language",
"Hyper Text Markup Language",
"High Text Markdown Language",
],
answer: "Hyper Text Markup Language"
}
];
const getRandomQuestion=(arr)=> {
return arr[Math.floor(Math.random() * arr.length)];
}
const getRandomComputerChoice=(arr)=> {
return arr[Math.floor(Math.random() * arr.length)];
}
const getResults=(obj,choice)=> {
if (choice==questions[questions.indexOf(obj)].answer) {
return "The computer's choice is correct!";
}
else {
return `The computer's choice is wrong. The correct answer is: ${questions[questions.indexOf(obj)].answer}`;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game
https://www.freecodecamp.org/learn/full-stack-developer/lab-quiz-game/lab-quiz-game