Tell us what’s happening:
I have completed up to step 10
spent loads of time but cant seem to get the solution
I broadly understand what they want me to do but I am not sure if I am using the correct parameters
Your advice would be greatly appreciated
Thank you
Your code so far
const questions = []
const question1 = {
category: "Global knowledge",
question: "Capital of Bangladesh?",
choices:['Dhaka', 'Sylhet', 'London'],
answer:"Dhaka"
};
const question2 = {
category: "Local knowledge",
question: "What season is in August?",
choices:['Winter', 'Spring', 'Summer'],
answer:"Summer"
};
const question3 = {
category: "History",
question: "What year did Bangladesh take part in the war?",
choices:['1972', '1970', '1968'],
answer:"1972"
};
const question4 = {
category: "Fun fact",
question: "When is valentines day?",
choices:['14th Feb', '16th Feb', '20th Feb'],
answer:"14th Feb"
};
const question5 = {
category: "what year is it?",
question: "When is valentines day?",
choices:['2025', '2024', '2026'],
answer:"2025"
};
// This is a crucial step, you push all the arrays into the questions array
questions.push(question1, question2, question3, question4, question5);
const getRandomQuestion = (questions)=>{
let randomQuestion = Math.floor(Math.random() * questions.length);
let randomElement = questions[randomQuestion]
return randomElement;
}
console.log(getRandomQuestion(questions)) // finally the correct output
const getRandomComputerChoice = (choices)=>{
let randomChoice = Math.floor(Math.random() * choices.length);
let randomElement2 = choices[randomChoice]
return randomElement2;
}
const getResults = (getRandomQuestion,getRandomComputerChoice ) =>{
if ( randomElement2 === randomElement ){
return "The computer's choice is correct!"
} else if {
`The computer's choice is wrong. The correct answer is: ${question.answer.value}`
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game