Tell us what’s happening:
I don’t see what I’m doing wrong. I’m stuck on the get results function .
Your code so far
let questions = [
{
category: "name",
question: "your name?",
choices: ["dave","josh","tim"],
answer: "tim",
},
{
category: "age",
question: "your age?",
choices: ["22","33","44"],
answer: "44",
},
{
category: "birth date",
question: "your birth date?",
choices: ["02/06/2004","11/14/1961","01/23/1968"],
answer: "11/14/1961",
},
{
category: "address",
question: "your address?",
choices: ["mockingbird lane","north portland avenue", "batchelder street"],
answer: "mockingbird lane",
},
{
category: "contact method",
question: "contact method?",
choices: ["Text","smoke signals","Email"],
answer: "smoke signals",
}
];/*
let rndmNum = Math.round(Math.random() * questions.length) + 5;
for(let i=0;i < questions.length;i++){
let rndmQ = questions[i].question;
console.log(rndmQ)
}
for(let i = 0;i < questions.length;i++){
let answers = questions[i].answer
console.log(answers)
}
*/
let rndmNum = Math.floor(Math.random() * questions.length)
function getRandomQuestion(questions){
return questions[rndmNum]
}
//console.log(questions.length)
let rndmChoice = Math.
round(Math.random() * questions[rndmNum])
//console.log(questions)
function getRandomComputerChoice(choices){
return choices[rndmNum]
}
function getResults(question, choice){
let randomChoice = choice[randomNum];
let randomQ = questions[rndmNum].choices;
if(randomQ === randomChoice){
return "The computer's choice is correct!"
}else{
return "The computer's choice is wrong. The correct answer is: " + question;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15
Challenge Information:
Build a Quiz Game - Build a Quiz Game