Tell us what’s happening:
The 9th test fails with message: question key should have the value of a string… which it has, the same as category.
Your code so far
const questions = [
{
category: 'science',
question: 'Water boiling point in C degrees',
choices: ['75', '105', '100'],
answer: '100'
},
{
category: 'math',
question: 'What is the square root of 100',
choices: ['1', '5', '10'],
answer: '10'
},
{
category: 'spanish',
question: 'Translate the word Tomato to spanish',
choices: ['Lechuga', 'Tomate', 'Rábano'],
answer: 'Tomate'
},
{
category: 'Movies',
question: 'Character name of SpiderMan',
choices: ['Peter Parker', 'Luke Cage', 'Clark Kent'],
answer: 'Peter Parker'
},
{
category: 'Music',
question: 'Complete We all live in a',
choices: ['Beautiful House', 'Yellow Submarine', 'Wonderful World'],
answer: 'Yellow Submarine'
}
];
function getRandomQuestion(questions) {
return questions[Math.floor(Math.random() * questions.length)];
};
function getRandomComputerChoice(choices) {
return choices[Math.floor(Math.random() * choices.length)];
};
function getResults(quest, choice) {
if (choice === quest.answer) {
return "The computer's choice is correct!";
} else {
return `The computer's choice is wrong. The correct answer is: ${quest.answer}`;
}
};
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game