Tell us what’s happening:
code works but can pass step 13. Not sure what it wants?
Your code so far
const questions = [
{
category: "color",
question: "What is my favorite color?",
choices: ["Blue", "Red", "Purple"],
answer: "Purple",
},
{
category: "Birthplace",
question: "Which country was I born in?",
choices: ["America", "Germany", "Norway"],
answer: "Germany",
},
{
category: "Video Games",
question: "What is my favorite video game franchise?",
choices: ["Call of Duty", "Bioshock", "Dark Souls"],
answer: "Dark Souls",
},
{
category: "Anime",
question: "What is my favorite anime?",
choices: ["Clannad", "Attack on Titan", "Sword Art Online"],
answer: "Clannad",
},
{
category: "MCU/DCU",
question: "Who is my favorite Marvel/ DC character?",
choices: ["Deadpool", "Dr. Manhattan", "Superman"],
answer: "Dr. Manhattan",
},
];
function getRandomQuestion(questions) {
let random = Math.floor(Math.random() * questions.length);
let randomQuestion = questions[random];
return randomQuestion;
};
function getRandomComputerChoice(choices) {
let randomC = Math.floor(Math.random() * choices.length);
let computerChoice = choices[randomC];
return computerChoice;
};
let randQuest = getRandomQuestion(questions)
function getResults(quest, compChoice) {
if (compChoice === quest.answer) {
return "The computer's choice is correct!";
} else {
return `The computer's choice is wrong. The correct answer is: ${randQuest.answer}`;
}
}
console.log(getRandomQuestion(questions));
console.log(getRandomComputerChoice(questions));
console.log(getResults(getRandomQuestion, getRandomComputerChoice));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game