Tell us what’s happening:
Ive been trying to find the problem for like an hour now can someone help me please?
4. The question key should have the value of a string representing a question.
Your code so far
const questions = [
{
category: "Math",
question: "What is 2 + 2?",
choices: ["5", "2", "4"],
answer: "4"
},
{
category: "Geography",
question: "Where is France?",
choices: ["Europa", "Asia", "Africa"],
answer: "Europa"
},
{
category: "History",
question: "Where is Napoleon from?" ,
choices: ["France", "Germany", "America"],
answer: "France"
},
{
category: "Biology",
question: "How many chromosomes in a human body",
choices: ["44", "46", "48"],
answer: "46"
},
{
category: "Coding",
question: "What language am i learning now?",
choices: ["Python", "JS", "Java"],
answer: "JS"
}
]
function getRandomQuestion(questionsArray){
const randomIndex = Math.floor(Math.random() * questionsArray.length)
return questionsArray[randomIndex]
}
function getRandomComputerChoice(choicesArray){
const randomIndex = Math.floor(Math.random() * choicesArray.length)
return choicesArray[randomIndex]
}
function getResults(question, computerChoice){
if(computerChoice === question.answer){
return `The computer's choice is correct!`
}
else{
return `The computer's choice is wrong. The correct answer is: ${question.answer}`
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game