Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

Can someone help to see what am I missing with my code? I really don’t know how to progress

Your code so far

const questions = [];

const question1 = {
  category: "History",
  question: "what's the real name of Pancho Villa?",
  choices: ["David Villa", "Francisco Villa", "Doroteo Arango"],
  answer: "Doroteo Arango"
};

const question2 ={
  category: "Trivia",
  question: "In which year was Sunbather by Deafheaven released?",
  choices: ["2011", "2015", "2013"],
  answer: "2013"
};

const question3 ={
  category: "Science",
  question: "Which is the most present element in the organical things?",
  choices: ["oxygen", "carbon", "blood"],
  answer: "carbon"
};

const question4 ={
  category: "literature",
  question: "who wrote the novel the stranger",
  choices: ["Mark Twain", "Albert Camus", "Jorge Luis Borges"],
  answer: "Albert Camus"
};

const question5 ={
  category: "Programming",
  question: "Which of the following programming languages are you learning with this excersise?",
  choices: ["C++", "Python", "JavaScript"],
  answer: "JavaScript"
};

function getRandomQuestion () {
  let randomQuestion = Math.floor(Math.random()* questions.length)
 return questions[randomQuestion];
}
function getRandomComputerChoice () {
  let randomComputerChoice = Math.floor(Math.random()* choices.length)
  return choices[randomComputerChoice];
}
function getResults (question, randomComputerChoice) {
  if (randomComputerChoice === answer){
  return "The computer's choice is correct!"}
  else if (randomComputerChoice !== answer) {
    return `The computer's choice is wrong. The correct answer is:${answer}`
  }
};
console.log(questions.question1)

Your browser information:

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

Challenge Information:

Build a Quiz Game - Build a Quiz Game

Hi @mio_min_mio

  • 1. You should create an array named questions.

  • Failed:2. The questions array should contain at least five objects, each having the keys category, question, choices, and answer.

The questions array should contain the objects.

Happy coding

Ok, but I don’t understand the difference between doing this and the code that I made before

const questions = [

{

category: “History”,

question: “what’s the real name of Pancho Villa?”,

choices: [“David Villa”, “Francisco Villa”, “Doroteo Arango”],

answer: “Doroteo Arango”

},

{

category: “Trivia”,

question: “In which year was Sunbather by Deafheaven released?”,

choices: [“2011”, “2015”, “2013”],

answer: “2013”

},

{

category: “Science”,

question: “Which is the most present element in the organical things?”,

choices: [“oxygen”, “carbon”, “blood”],

answer: “carbon”

},

{

category: “literature”,

question: “who wrote the novel the stranger”,

choices: [“Mark Twain”, “Albert Camus”, “Jorge Luis Borges”],

answer: “Albert Camus”

},

{

category: “Programming”,

question: “Which of the following programming languages are you learning with this excersise?”,

choices: [“C++”, “Python”, “JavaScript”],

answer: “JavaScript”

}

]

I tried to compare it to the recipe maker but I don’t understand why in those whe called the objects with the const recipe1 and here we don’t have to do it.

I only got problems with the steps 11, 13 and 14 with what I have advanced. Can someone help me, please?

const questions = [

{

category: “History”,

question: “what’s the real name of Pancho Villa?”,

choices: [“David Villa”, “Francisco Villa”, “Doroteo Arango”],

answer: “Doroteo Arango”

},

{

category: “Trivia”,

question: “In which year was Sunbather by Deafheaven released?”,

choices: [“2011”, “2015”, “2013”],

answer: “2013”

},

{

category: “Science”,

question: “Which is the most present element in the organical things?”,

choices: [“oxygen”, “carbon”, “blood”],

answer: “carbon”

},

{

category: “literature”,

question: “who wrote the novel the stranger?”,

choices: [“Mark Twain”, “Albert Camus”, “Jorge Luis Borges”],

answer: “Albert Camus”

},

{

category: “Programming”,

question: “Which of the following programming languages are you learning with this excersise?”,

choices: [“C++”, “Python”, “JavaScript”],

answer: “JavaScript”

}

]

function getRandomQuestion (question) {

let randomQuestion = Math.floor(Math.random()* question.length)

return questions[randomQuestion];

}

function getRandomComputerChoice (choices) {

let randomComputerChoice = Math.floor(Math.random()* choices.length)

return choices[randomComputerChoice];

}

function getResults (question, randomComputerChoice) {

if (question.answer === randomComputerChoice){

return “The computer’s choice is correct!”}

else if (randomComputerChoice !== answer) {

return \`The computer's choice is wrong. The correct answer is:${answer}\`

}

};

console.log(questions)

This way fulfills the request of the User Story.

Don’t use other lessons or challenges as a guide. Just follow the instructions for this challenge.

What’s the problem you’re having?

I already solved it, it was a typo problem. Thank you for your help, it´s just that sometimes it´s hard to understand some steps by oneself.