Tell us what’s happening:
only issue is the getResults function all steps are ticked except last 11 to 14 which all belong to that one last function surely there’s one or two changes that will fix it.
can you help me with it?
Your code so far
const questions = [{
category: "color?",
question: "what is your favorite color?",
choices: ["blue","pink","green"],
answer: "green"
},
{
category: "living place?",
question: "do you like living there ?",
choices: ["Bursa","Ankara","Istanbul"],
answer: "Istanbul"
},
{
category: "field of study?",
question: "do you grageuated?",
choices: ["computer","Math","teacher"],
answer: "computer"
},
{
category: "cooking?",
question: "What is your favorite food?",
choices: ["Pizza","Ege","Rice"],
answer: "Ege"
},
{
category: "sports?",
question: "What is your favorite sport?",
choices: ["football", "volleyball","swimming"],
answer: "volleyball"
}];
const getRandomQuestion = (questions) => {
const randomIndex = Math.floor(Math.random() * questions.length);
return questions[randomIndex];
};
const getRandomComputerChoice = (choices) => {
const randomIndex = Math.floor(Math.random() * choices.length);
return choices[randomIndex];
};
const getResults = (question, computerChoice) => {
computerChoice = getRandomComputerChoice(questions.choices);
question = getRandomQuestion(questions);
if(computerChoice === question){
return "The computer's choice is correct!";
} else {
return `The computer's choice is wrong. The correct answer is: ${computerChoice}`;
};
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game