Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

The output of my code is correct. But for some reason unknown to me, I can’t pass step 14.

Your code so far

const obj1 = {
  category: "science",
  question: "What is a Cactus?",
  choices: ["A map", "A toy", "A plant"],
  answer: "A plant"
}

const obj2 = {
  category: "music",
  question: "What is a Piano?",
  choices: ["A phone", "A laptop", "A musical instrument"],
  answer: "A musical instrument"
}

const obj3 = {
  category: "police",
  question: "What is a gun?",
  choices: ["A cord", "A table", "A weapon"],
  answer: "A weapon"
}

const obj4 = {
  category: "computer",
  question: "What is a keyboard?",
  choices: ["A bucket", "A gift", "A computer hardware"],
  answer: "A computer hardware"
}

const obj5 = {
  category: "office",
  question: "What is a pen?",
  choices: ["A boy", "A girl", "A stationerry"],
  answer: "A stationerry"
}

let questions = [obj1, obj2, obj3, obj4, obj5]

function getRandomQuestion(arr){
  const randomIndex = Math.floor(Math.random() * arr.length)
 const randomQuestion  = arr[randomIndex]
 return randomQuestion
} 


function getRandomComputerChoice(arr) {
  let randomIndex = Math.floor(Math.random() *arr.length)
  return arr[randomIndex] 
}

function getResults(obj, choice)  {
  if (obj.answer.includes(choice)){
    return `The computer's choice is correct!`
  } else {
    return `The computer's choice is wrong. The correct answer is: ${obj.answer}`
  } 
} 

const loggg = "A plant"
console.log(getResults(obj1, loggg))

Your browser information:

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

Challenge Information:

Build a Quiz Game - Build a Quiz Game

Hi @morgansamuel960 ,

Is this an exact equality comparison?

Happy coding!

1 Like

Thank you! Issue solved