Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I have tried to pass number 8 but is not working and the code is working fine

Your code so far

const questions = [
{
  category: "Human",
  question: "Are you a man?",
  choices: ["Man", "Woman", "both"],
  answer: "Man"
},
{
  category: "Animal",
  question: "Which animal is this?",
  choices: ["cat", "lion", "monkey"],
  answer: "cat"
},
{
  category: "bird",
  question: "Which bird is this?",
  choices: ["eagle", "housefly", "ant"],
  answer: "eagle"
},
{
  category: "Object",
  question: "what is this?",
  choices: ["pin", "paper", "pen"],
  answer: "paper"
},
{
  category: "color",
  question: "Which color is this?",
  choices: ["Red", "Green", "yellow"],
  answer: "Green"
}
]

function getRandomQuestion(questions){
  return questions[Math.floor(Math.random() * questions.length)].question
}
console.log(getRandomQuestion(questions))


Your browser information:

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

Challenge Information:

Build a Quiz Game - Build a Quiz Game

1 Like

hello bro, the problem in your code why the step number 8 is not passing because: they told you to choose random object from the questions array means you have to output from that function the random all object that contain everything the question and the category and the answer but what you did is: you just output the question key from the object this is why it failed with you, small hint, there is just one small thing you remove it from the return statment and boooom, everything will be done, good luck tell me what you did about it