Tell us what’s happening:
I don’t know what is wrong with step no. 13.
is it a typo or the return data is not what expected?
Your code so far
const questions = [];
const question1 = {
category:"History",
question: "What was the year of Mexican Independece?",
choices: ["1801", "1700", "1810"],
answer: "1810"
}
const question2 = {
category:"History",
question: "Who was the first french Emperor?",
choices: ["Napoleon", "Jaqces de Soir", "Ney"],
answer: "Napoleon"
}
const question3 = {
category: "Science",
question: "What is the best medicine?",
choices: ["Ki-Cab", "Omeprazol", "Yakult"],
answer: "Ki-Cab"
}
const question4 = {
category: "Science",
question: "Who is the best lab?",
choices: ["Faizer", "Bayer", "Carnot"],
answer: "Carnot"
}
const question5 = {
category: "Science",
question: "Who is the best rep?",
choices: ["Josse", "Fabia", "Luis"],
answer: "Josse"
}
questions.push(question1, question2, question3, question4, question5);
let random = Math.floor(Math.random() * 5) //For the Questions
let random1 = Math.floor(Math.random() * 3) // For the choices
const { choices: randomChoice } = questions[random]; // Choices destructing
function getRandomQuestion (questions) {
return questions[random];
}
//console.log(getRandomQuestion(questions));
function getRandomComputerChoice (randomChoice) {
return randomChoice[random1];
}
//console.log(getRandomComputerChoice(randomChoice));
let ants1 = getRandomQuestion(questions);
let ants2 = getRandomComputerChoice(randomChoice);
let { answer } = questions[random]
function getResults (ants1, ants2) {
if(ants1.answer === ants2) {
return "The computer's choice is correct!";
} else {
return `The computer's choice is wrong. The correct answer is: ${answer}`
}
}
console.log(getResults(ants1, ants2));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 OPR/102.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game