Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I don’t pass tests 8 and 9 but I dont get what i’m doing wrong.

and I pass test 13 but questionObj.answer gives undefined. How do I get the answer thas belongs to the question?

Your code so far

let questions=[
{
 category:"color? ", 
 question:"what is your favorite color?",
 choices:["blue","pink","green"],
 answer:"green",
},
{
 category:"living place?", 
 question:"Where do you live?",
 choices:["Bursa","Ankara","Istanbul"],
 answer:"Istanbul",
},
{
 category:"job?", 
 question:"What is your job?",
 choices:["computer-specialist","pro tennisplayer","teacher"],
 answer:"computer-specialist",
},
{
   category:"cooking?", 
 question:"What is your favorite food?",
 choices:["Pizza","Egg","Rice"],
 answer:"Pizza",
},
{
 category:"sports?", 
 question:"What is your favorite sport?",
 choices:["football", "volleyball","swimming"],
 answer:"football",
}

];

let currentQuestionIndex = null;

function getRandomQuestion(){
 currentQuestionIndex = Math.floor(Math.random() * questions.length);
  return questions[currentQuestionIndex].question;
}

function getRandomComputerChoice() {
let choices = questions[currentQuestionIndex].choices;
  let choiceIndex = Math.floor(Math.random() * choices.length);
  return choices[choiceIndex];
}

let questionObj = getRandomQuestion()
console.log(questionObj)

let computerChoice = getRandomComputerChoice() 
console.log(computerChoice)

function getResults(questionObj, computerChoice) {
  if (computerChoice === questionObj.answer) {
    return "The computer's choice is correct!";
  } else {
    return `The computer's choice is wrong. The correct answer is: ${questionObj.answer}`;
  }
}
 
console.log(getResults(questionObj, 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/141.0.0.0 Safari/537.36

Challenge Information:

Build a Quiz Game - Build a Quiz Game

Here are some troubleshooting steps you can follow. Focus on one test at a time:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the first failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.

  1. You should have a function named getRandomQuestion that takes an array of questions as a parameter

Your function has no parameters.

function getRandomQuestion(){