Tell us what’s happening:
Im able to get and display the choices arrays.
But still the test 8 are not able to pass the test
Your code so far
const questions = [{
"category":"food",
"question":"monkey favorite food?",
"choices":["apple","banana","burito"],
"answer":"banana"
},
{
"category":"anime",
"question":"best selling manga?",
"choices":["OPM","OP","DB"],
"answer":"OP"
},
{
"category":"food",
"question":"panda favorite food?",
"choices":["apple","bamboo","charcoal"],
"answer":"bamboo"
},
{
"category":"color",
"question":"what is the color of the grass?",
"choices":["pink","blue","green"],
"answer":"green"
},
{
"category":"tech",
"question":"who own facebook?",
"choices":["Zuckerberg","Steve Job","Bill Gates"],
"answer":"Zuckerberg"
}
];
function getRandomComputerChoice(choice) {
const randomChoice = Math.floor(Math.random() * choice.length)
if (randomChoice === 0){
return choice[randomChoice].choices[0]
} else if (randomChoice === 1){
return choice[randomChoice].choices[1]
} else {
return choice[randomChoice].choices[2]
}
// const questionChoice = randomChoice.question
// return questionChoice
// return choice[randomChoice]
}
console.log(getRandomComputerChoice(questions))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game