Tell us what’s happening:
For some reason I can’t pass test 4 in the project
Your code so far
const questions = [
{
category: "football",
question: "Which English team has won the most champions leagues?",
choices: ["Manchester United", "Chelsea", "Liverpool"],
answer: "Liverpool"
},
{
category: "cricket",
question: "Which year did Pakistan win the Champions Trophy?",
choices: ["2016", "2017", "2018"],
answer: "2017"
},
{
category: "Jojo's",
question: "Which year did the Stardust Crusaders defeat DIO?",
choices: ["1987", "1988", "1989"],
answer: "1987"
},
{
category: "Naruto",
question: "Who is the goat of Naruto?",
choices: ["Shikamaru", "Naruto", "Jiraiya"],
answer: "Shikamaru"
},
{
category: "OG Jojoverse",
question: "Which OG Jojo part is the best",
choices: ["Battle Tendency", "Stardust Crusaders", "Diamond is Unbreakable"],
answer: "Stardust Crusaders"
}
]
function getRandomQuestion(arr) {
const randomQuestion = Math.floor(Math.random() * arr.length)
return arr[randomQuestion]
}
function getRandomComputerChoice(availableChoices){
const computerAnswer = Math.floor(Math.random() * availableChoices.length)
return availableChoices[computerAnswer]
}
function getResults(daQuestion, daAnswer){
if (daQuestion.answer === daAnswer) {
return "The computer's choice is correct!"
} else {
return `The computer's choice is wrong. The correct answer is: ${daQuestion.answer}`
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game