Tell us what’s happening:
I am failing tests 11, 13, and 14, but my output is correct. I don’t understand what to do next.
Your code so far
const questions = [
{
category: "Science",
question: "Who?",
choices: ["Here", "There", "Everywhere"],
answer: "Here",
},
{
category: "Tech",
question: "Where?",
choices: ["Here", "There", "Everywhere"],
answer: "There"
},
{
category: "Engineering",
question: "When?",
choices: ["Here", "There", "Everywhere"],
answer: "Everywhere",
},
{
category: "Math",
question: "What?",
choices: ["Here", "There", "Everywhere"],
answer: "Here",
},
{
category: "Arts",
question: "Why?",
choices: ["Here", "There", "Everywhere"],
answer: "There",
}
];
function getRandomQuestion(question) {
let randomNum = Math.floor(Math.random() * 5);
const objectQ = questions[randomNum];
return objectQ;
}
const questionObj = getRandomQuestion();
console.log(questionObj);
function getRandomComputerChoice(choices) {
let randomNum = Math.floor(Math.random() * 3);
return choices[randomNum];
}
const choiceObj = getRandomComputerChoice;
function getResults(answer, choices) {
let randomNum = Math.floor(Math.random() * 5);
const chosenQ = questions[randomNum].answer;
const chosenC = questions[randomNum].choices[Math.floor(Math.random() *3)];
if (chosenQ === questions[randomNum].choices[Math.floor(Math.random() * 3)])
{
return "The computer's choice is correct!";
} else {
return `The computer's choice is wrong. The correct answer is: ${chosenC}`;
}}
console.log(getResults());
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game

