Build a Quiz Game - Build a Quiz Game Test 9

Tell us what’s happening:

I cannot pass test 9. All other tests pass. And when I use console.log to check, it pulls the correct information. Not sure what I am missing. Any help is much appreciated. Thank you.

  1. You should have a function named getRandomComputerChoice that takes the array of the available choices as a parameter, and returns a random answer to the selected question.

Your code so far

let questions = [
  {
    category: "Favorite Color",
    question: "What is Princess Peach's favorite color?",
    choices: ["blue", "peach", "pink"],
    answer: "pink",
  },
  {
    category: "Favorite Food",
    question: "What food is Sonic The Hedgehog's favorite?",
    choices: ["power-ups", "cheeseburgers", "pizza"],
    answer: "cheeseburgers",
  },
  {
    category: "Location",
    question: "What city are Mario and Luigi from?",
    choices: ["Chicago", "Denver", "Brooklyn"],
    answer: "Brooklyn",
  },
  {
    category: "Favorite Stunt",
    question: "What is Sonic the Hedgehog's favorite stunt?",
    choices: ["super-speed", "spin-dash", "spin-attack"],
    answer: "spin-attack",
  },
  {
    category: "Age",
    question: "Who is older? Mario or Luigi?",
    choices: ["Mario", "Luigi", "They are twins"],
    answer: "They are twins",
  }
]

let randomNumber = Math.floor(Math.random() * questions.length);
let randomNumber2 = Math.floor(Math.random() * getRandomQuestion().choices.length);

function getRandomQuestion(array){
  const randomQuestion = questions[randomNumber];
  return randomQuestion;
};
const pickedQuestion = getRandomQuestion();

function getRandomComputerChoice(choices){
  let questionChoices = getRandomQuestion().choices;
  const randomChoice = questionChoices[randomNumber2];
  return randomChoice;
};
const pickedComputerChoice = getRandomComputerChoice();

function getResults(pickedQuestion, pickedComputerChoice){
  if(pickedQuestion.answer == pickedComputerChoice){
    return ("The computer's choice is correct!")
  } else {
    return (`The computer's choice is wrong. The correct answer is: ${pickedQuestion.answer}`);
  };
};

console.log(pickedQuestion);
console.log(pickedComputerChoice);
console.log (getResults(pickedQuestion, pickedComputerChoice))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build a Quiz Game - Build a Quiz Game
https://www.freecodecamp.org/learn/full-stack-developer/lab-quiz-game/lab-quiz-game

hmm, doesn’t get RandomQuestion expect an argument?

in your case, you don’t give it one and then even if you don’t your function (getRandomQuestion) doesn’t use it?

are you using the parameter of this function?

Thank you so much. This helped me get where I needed to be to finally pass the test.