Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I’ve been struggling for a while with user histories above 8.

Your code so far

const questions = [
  {
    category: 'action',
    question: 'Who was creep opponenet?', 
    choices: ['Vicktor', 'Michael Jordan', 'FloydMaythear'], 
    answer: 'Vicktor' 
  }, 
  
  {
    category: 'music',
    question: 'Who created the 5th symphony?', 
    choices: ['Mozart', 'Beethoven', 'Basch'], 
    answer: 'Mozart' 
  }, 

  {
    category: 'movie',
    question: "What brand's car was Sally (car's girlfriend)? ", 
    choices: ['Mercedes Benz', 'Porsche', 'Bentley'], 
    answer: 'Porsche' 
  }, 

  {
    category: 'music',
    question: "Who's been the most famous artist from USA?", 
    choices: ['Drake', 'Michael Jackson', 'John Lennon'], 
    answer: 'Michael Jackson' 
  }, 

  {
    category: 'tech',
    question: "What's the device used to protect a local network?", 
    choices: ['router', 'wifi', 'firewall'], 
    answer: 'firewall' 
  }
]

const getRandomQuestion = (obj) => {
  const randomNum = Math.floor(Math.random(1) * obj.length)

  console.log(obj[randomNum].question)


}

getRandomQuestion(questions)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:153.0) Gecko/20100101 Firefox/153.0

Challenge Information:

Build a Quiz Game - Build a Quiz Game

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @edgshift,

You should have a function named getRandomQuestion that takes an array of questions as a parameter and returns a random question object from the array.

What does getRandomQuestion return?

Happy coding