I’m getting errors 11, 13, and 14. Could you help me figure out what’s wrong?
const A={
category:'Geographical Knowledge',
question:'What is the capital of France?',
choices:['as','ad','af'],
answer:'as',
};
const B={
category:'Scientific Explanation',
question:'How does photosynthesis work in plants?',
choices:['as','ad','af'],
answer:'ad',
};
const C={
category:'Open-ended Opinion',
question:'If you could change one thing about the world, what would it be?',
choices:['as','ad','af'],
answer:'af',
};
const D={
category:'Mathematical Problem-solving',
question:'Solve for?',
choices:['ae','ad','af'],
answer:'ae',
};
const E={
category:'Geographical Knowledge',
question:'What is the capital of China?',
choices:['aa','ad','af'],
answer:'aa',
};
const questions=[A,B,C,D,E];
const arrQuestions=questions;
function getRandomQuestion(arrQuestions){
const random=Math.floor(Math.random()*arrQuestions.length);
return arrQuestions[random];
}
const questionObject=getRandomQuestion(arrQuestions);
const arrChoices=questionObject.choices;
function getRandomComputerChoice(arrChoices){
const random=Math.floor(Math.random()*arrChoices.length);
return arrChoices[random];
}
const computerChoice=getRandomComputerChoice(arrChoices);
function getResults(questionObject,computerChoice){
if(questionObject.answer === computerChoice){
return "The computer's choice is correct!";
}else{
return `The computer's choice is wrong.The correct answer is: ${questionObject.answer}`;
}
}
const result=getResults(questionObject,computerChoice);
console.log(result);