Tell us what’s happening:
I’m not passing tests 11, 13, and 14, but passing 12 so I’m very confused. How is it not two parameters, one for an object and the other for the choice?
Your code so far
const questions = [
{
category: "personal",
question: "What's the phobia of clowns called?",
choices: ["Coulrophobia", "Aracnophobia", "Agoraphobia"],
answer: "Coulrophobia",
},
{
category: "personal",
question: "What is the name of my favorite book?",
choices: ["The Road", "IT", "Blood Meridian"],
answer: "The Road",
},
{
category: "trivia",
question: "What is the name of the famous ship that crashed into an iceberg?",
choices: ["Titanic", "USS Philidelphia", "The Montauk"],
answer: "Titanic",
},
{
category: "trivia",
question: "Where was Mothman sighted?",
choices: ["Point Pleasant", "Philidelphia", "Chicago"],
answer: "Point Pleasant",
},
{
category: "other",
question: "What is the meaning of life, the universe, and everything?",
choices: ["47", "56", "42"],
answer: "42",
}
];
function getRandomQuestion(array) {
let rNum = Math.floor(Math.random() * array.length);
return questions[rNum];
}
const randomQ = getRandomQuestion(questions)
function getRandomComputerChoice(array){
let rNum = Math.floor(Math.random() * array.length);
return array[rNum]
}
const comAnswer = getRandomComputerChoice(randomQ.choices);
//*Good to this point*//
function getResults(object, choice){
let answer = object.answer;
let comChoice = choice
if (comChoice === answer){
return "The computer's choice is correct!"
}
else if (comChoice !== answer){
return `The computer's choice is wrong. The correct answer is ${answer}`;
}
}
console.log();
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game