Tell us what’s happening:
My tests 11, 13 and 14 keep failing and I can’t seem to find the issue.
Can someone help me out?
Your code so far
const questions = [];
const question1 = {
category: "MCQ",
question: "What is your name?",
choices:["Ajak", "Garang", "Mathiang"],
answer: "Ajak"
}
const question2 = {
category: "MCQ",
question: "Which school do you go to?",
choices:["JKUAT", "USIU", "KU"],
answer: "USIU"
}
const question3 = {
category: "MCQ",
question: "Which sport do you play?",
choices:["Basketball", "Football", "Netball"],
answer: "Basketball"
}
const question4 = {
category: "MCQ",
question: "Who is your role model?",
choices:["Jordan", "Lebron", "Giannis"],
answer: "Giannis"
}
const question5 = {
category: "MCQ",
question: "Where do you live?",
choices:["School", "Qwetu", "Queens"],
answer: "Qwetu"
}
questions.push(question1, question2, question3, question4, question5);
// console.log(questions)
function getRandomQuestion(questions){
const random = Math.floor(Math.random()*questions.length)
return questions[random]
}
// console.log(getRandomQuestion(questions))
function getRandomComputerChoice(choices){
const random = Math.floor(Math.random()* choices.length)
return choices[random]
}
// console.log(getRandomComputerChoice(questions[1].choices))
function getResults(questionsObj, compChoice){
if(questionsObj.answer === compChoice){
return "The computer's choice is correct!"
}else{
return `The computer's choice is wrong. The correct answer is ${questionsObj.answer}`
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game