Tell us what’s happening:
Hello, I’m having trouble with identifying what is not letting me pass the tests, the output seems to be working for each function, I’d like some help please.
Your code so far
let questions = [];
const q1 = {
category: "singer" ,
question: "Who sang the title song for the latest Bond film, No Time to Die?" ,
choices: ["Adele", "Sam Smith", "Billie Eilish"] ,
answer: "Billie Eilish"
};
const q2 = {
category: "Country" ,
question: "Which flies a green, white, and orange (in that order) tricolor flag?" ,
choices: ["Ireland", "Ivory Coast", "Italy"] ,
answer: "Ireland"
};
const q3 = {
category: "Smartphone Maker" ,
question: "What company makes the Xperia model of smartphone?" ,
choices: ["Samsung", "Sony", "Nokia"] ,
answer: "Sony"
};
const q4 = {
category: "Famous place" ,
question: "Which city is home to the Brandenburg Gate?" ,
choices: ["Vienna", "Zurich", "Berlin"] ,
answer: "Berlin"
};
const q5 = {
category: "Fruit" ,
question: "Which of the following is NOT a fruit?" ,
choices: ["Rhubarb", "Tomato", "Avocado"] ,
answer: "Rhubarb"
};
questions.push(q1, q2, q3, q4, q5);
function getRandomQuestion(questions) {
return questions[Math.floor(Math.random() * questions.length)];
}
console.log(getRandomQuestion(questions))
function getRandomComputerChoice(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
console.log(getRandomComputerChoice(q5.choices));
let rq = getRandomQuestion(questions);
let rcc = getRandomComputerChoice(rq.choices);
function getResults(qobj, cchoice) {
if(qobj.answer === cchoice) {
return "The computer's choice is correct!";
}
else if (rq.answer !== rcc) {
return "The computer's choice is wrong. The correct answer is: " + rq.answer;
}
}
console.log(rq);
console.log(rcc);
console.log(getResults(rq, rcc.choices));
console.log(typeof(rq))
console.log(typeof(rcc))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game