Tell us what’s happening:
I’m missing something here that I can’t wrap my head around. I cannot seem to pass 11-13. I think I am misunderstanding how the questions and answers are supposed to come together for the getResults function.
Your code so far
const questions = [
{
category: "Animal",
question: "What is the best animal?",
choices: ['Dog', 'Cat', 'Fish'],
answer: 'Dog'
},
{
category: "Drink",
question: "What is the best drink?",
choices: ['Soda', 'Water', 'Tea'],
answer: 'Water'
},
{
category: "Food",
question: 'What is the best food?',
choices: ['Beef', 'Chicken', 'Ice Cream'],
answer: 'Ice Cream'
},
{
category: "Movie",
question: 'What is the best movie?',
choices: ['Princess Bride', 'Three Amigos', 'Ghostbusters'],
answer: 'Princess Bride',
},
{
category: "Music",
question: 'What is the best music?',
choices: ['Jazz', 'Classical', 'Pop'],
answer: 'Classical'
}
];
function getRandomQuestion(questions) {
let randomQuestion = Math.floor(Math.random() * questions.length);
return questions[randomQuestion];
}
function getRandomComputerChoice(choices) {
let randomComputerChoice = Math.floor(Math.random() * choices.length);
return choices[randomComputerChoice];
}
function getResults(questions, choices) {
if (randomComputerChoice === answer)
return "The computer's choice is correct!"
else {
return `The computer's choice is wrong. The correct answer is: ${answer}`
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game