Tell us what’s happening:
iam trying to redo the lab for practicing but i failed to pass test number 9 although i get good results in console !
if someone could gimme a hint or tips and tricks so i can build up my coding muscles ![]()
Your code so far
const questions = [
{
category: 'Sports',
question: 'Who is the greatest athlete ever ?',
choices: ['M.Tricka', 'El-khateeb', 'H.Shehata'],
answer: 'M.Tricka',
},
{
category: 'Policy',
question: 'Who is the greatest athlete ever ?',
choices: ['M.Trickai', 'El-khateebi', 'H.Shehatai'],
answer: 'M.Trickai',
},
{
category: 'Crime',
question: 'Who is the greatest athlete ever ?',
choices: ['M.Trickaii', 'El-khateebii', 'H.Shehataii'],
answer: 'M.Trickaii',
},
{
category: 'Cinema',
question: 'Who is the greatest athlete ever ?',
choices: ['M.Trickaiii', 'El-khateebiii', 'H.Shehataiii'],
answer: 'M.Trickaiii',
},
{
category: 'SportsX',
question: 'Who is the greatest athlete ever ?',
choices: ['M.Trickaxi', 'El-khateebxi', 'H.Shehataxi'],
answer: 'M.Trickaxi',
},
]
function getRandomQuestion(arr) {
let randomIndex = Math.floor(Math.random() * arr.length)
return arr[randomIndex]
}
function getRandomComputerChoice(arr) {
arr = getRandomQuestion(questions).choices;
let randomIndex = Math.floor(Math.random() * 3)
return arr[randomIndex]
}
// console.log(questions)
console.log(getRandomComputerChoice())
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Challenge Information:
Build a Quiz Game - Build a Quiz Game
https://www.freecodecamp.org/learn/full-stack-developer/lab-quiz-game/lab-quiz-game