Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I don’know how to solve the tests 7, 11, 12 and 13

Your code so far

const questions = [
  {
    category : "Food",
    question : "Do you like tomatoes?",
    choices : ["Yes", "No", "It is irrelevant."],
    answer : "Yes"
       
  },

  {
    category : "Food",
    question : "Do you like tomatoes?",
    choices : ["Yes", "No", "It is irrelevant."],
    answer : "No"
  },

  {
    category : "Clothes",
    question : "Do you like dresses?",
    choices : ["Yes", "No", "It is irrelevant."],
    answer : "It's irrelevant"     
  },

  {
    category : "Travel",
    question : "Do you like travel?",
    choices : ["Yes", "No", "It is irrelevant."],
    answer : "No"       
  },

  {
    category : "Games",
    question : "Do you like travel?",
    choices : ["Yes", "No", "It is irrelevant."],
    answer : "No"  
  }
];


function getRandomQuestion(question) {
  const index = question.length;
  const randomIndex = Math.floor(Math.random()*index);
  return question[randomIndex];
}

console.log(getRandomQuestion(questions).answer);

function getRandomComputerChoice(questionChoices){
    const index = questionChoices.length;
    const randomIndexChoice = Math.floor(Math.random()*index);
  return questionChoices[randomIndexChoice];
}

console.log(getRandomComputerChoice(questions).answer);

function getResults(answer, computerAnswer) {
  //const questionAnswer = getRandomQuestion(question).answer;
  //const computerAnswer = getRandomComputerChoice(question).answer;
  if( answer === computerAnswer){
    return "The computer's choice is correct!";
  } else {
    return "The computer's choice is wrong. The correct answer is: " + answer;
  }

}

console.log(getResults(getRandomQuestion(questions).answer,getRandomComputerChoice(questions).answer));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0

Challenge Information:

Build a Quiz Game - Build a Quiz Game

What are tests 7, 11, 12 and 13?

Can you say what parts of your code you think should satisfy those tests and what debugging you’ve tried?

For example:
// tests completed
// console output
No
No
The computer’s choice is correct!

No
Yes
The computer’s choice is wrong. The correct answer is: It’s irrelevant

Please answer all of my questions.

Sorry,
I don’t know how to answer, “it’s irrelevant” isn’t written, I changed it to “it is irrelevant.” I’ve reset several times and it continues.

And at first it worked and I only had test 7 left.

You could answer by first saying what tests 7, 11, 12 and 13 are:

You would then next say what code you have written you think satisfies those requirements.

  1. The value of answer should be included in the choices array.

Why did you only answer part of one of the two questions?

Please answer those two questions above. Pretty please

I don`t know how to respond, but no problem.
Sorry for wasting your time. I’ll figure it out later with more JavaScript experience.

You figured out how to say what test 7 is. I am not sure why it is difficult for you to say what tests 11, 12, and 13 are? I am genuinely confused.


Can you say what about this you do not understand?

Test 1 says

You should create an array named questions.

The part of your code that is for that test is this part:

What are the parts of your code that you think do what tests 11, 12, and 13 ask for?

Hi there,

Please focus on this bit of the 9th user story:

You should have a function named getResults that takes the question object as the first parameter and the computer’s choice as the second parameter.

Your call to getRandomComputerChoice() is not correct. Wouldn’t you need to get the question object first so you can get that specific question’s choices to pass to getRandomComputerChoice()? What variables could you create then to use in your call to getResults()?