Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

Having issue on the 8th requirement
My code passed the rest expect the no 8

Your code so far

const questions = [];

const question1 = {
  category: 'Science',
  question: "What is the outermost layer of Earth's atmosphere called?",
  choices: ["Stratosphere", "Troposphere", "Exosphere"],
  answer: "Exosphere"
};

const question2 = {
  category: 'General Knowledge',
  question: "Which of the following is considered the world's fastest bird?",
  choices: ["Peregrine Falcon", "Ostrich", "Albatross"],
  answer: "Peregrine Falcon"
};

const question3 = {
  category: 'Science',
  question: 'Which element have the chemical symbol \"K\"?',
  choices: ["Calcium", "Krypton", "Potassium"],
  answer: "Potassium"
};

const question4 = {
  category: 'History',
  question: 'Who developed the theory of heliocentrism, which states that the Earth revolves around the sun?',
  choices: ["Galileo Galilei", "Nicolaus Copernicus", "Johannes Kepler"],
  answer: "Nicolaus Copernicus"
};

const question5 = {
  category: 'Biology',
  question: 'What is the Latin name for a giant panda?',
  choices: ["Felis catus", "Ailuropoda melanoleuca", "Pan troglodytes"],
  answer: "Ailuropoda melanoleuca"
};

questions.push(question1, question2, question3, question4, question5);

function getRandomQuestion(questions) {
  if (questions.length === 0) {
    console.log("No more questions!");
    return null;
  } else {
  const randomIndex = Math.floor(Math.random() * questions.length);
  const question = questions[randomIndex];
  return question;
  }
};
//console.log(getRandomQuestion(questions));

function getRandomComputerChoice(choices) {
  const randomIndex = Math.floor(Math.random() * choices.length);
  const choice = choices[randomIndex];
  return choice;
};
//console.log(getRandomComputerChoice(questions));

function getResults(questionObj,computerChoices){
  if (computerChoices.choice === questionObj.ans) {
    return "The computer's choice is correct!";
  } else {
    return "The computer's choice is wrong. The correct answer is: " + questionObj.answer;
  }
};
console.log(getResults(getRandomQuestion,getRandomComputerChoice));
console.log(getResults(getRandomQuestion,getRandomComputerChoice));

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/141.0.7390.96 Mobile/15E148 Safari/604.1

Challenge Information:

Build a Quiz Game - Build a Quiz Game

Here are some troubleshooting steps you can follow. Focus on one test at a time:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the first failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.

why are you calling getResult passing in two functions?

your issue would be with getResults, call your function correctly and check what it does:

console.log(getResults(questions[0], questions[0].answer));
console.log(getResults(questions[0], "not the answer"));

I tried amending the getReturn but not passing 11 and 12 but passed 13

you can respond to the questions above and share your updated code to get more help