Tell us what’s happening:
The code is not passing although the game seems to function properly. Am I doing something wrong or is there another way I need to code this in order to pass?
Your code so far
const questions = [
{
category: 'Padel',
question: 'Who were the number 1 seeds for 2024?',
choices:['tapia & coello', 'chingalan', 'lebron & dinenno'],
answer: 'tapia & coello',
},
{
category: 'Padel',
question: 'Who is the nicest padel player?',
choices:['agus', 'chingotto', 'paquito'],
answer: 'chingotto',
},
{
category: 'Padel',
question: 'Who is the most controversial padel player?',
choices:['tolito', 'lebron', 'galan'],
answer: 'lebron',
},
{
category: 'Padel',
question: 'Who were the super pives?',
choices:['stupa & dinenno', 'lebron & galan', 'chingotto & paquito'],
answer: 'stupa & dinenno',
},
{
category: 'Padel',
question: 'Who were the super pivas?',
choices:['delfi & bea', 'lebrona & galana', 'chingotta & paquita'],
answer: 'delfi & bea',
}
];
let randomQ;
const getRandomQuestion = () => {
const randomNum = Math.round(Math.random() * 4);
randomQ = randomNum;
const randomQuestion = questions[randomNum].question;
return randomQuestion
}
console.log(getRandomQuestion());
let computerChoice;
const getRandomComputerChoice = (randomQuestion) => {
const randomComputerChoice = questions[randomQuestion].choices[Math.round(Math.random() * 2)];
computerChoice = randomComputerChoice;
return randomComputerChoice
}
console.log(getRandomComputerChoice(randomQ));
const getResults = () => {
if (computerChoice === questions[randomQ].answer) {
return "The computer's choice is correct!"
} else {
return `The computer's choice is wrong. The correct answer is: ${questions[randomQ].answer}`
}
}
console.log(getResults());
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game