Tell us what’s happening:
Tests 11, 12 and 13 are failing. But when I try to manually check if the function is logging the correct output, the output looks right.
Your code so far
const q1 = {
category : 'MathQ1',
question : 'What is 5*2?',
choices : ['10', '100', '1000'],
answer : '10'
}
const q2 = {
category : 'MathQ2',
question : 'What is 5*100?',
choices : ['0.5', '500', '5000'],
answer : '500'
}
const q3 = {
category : 'MathQ3',
question : 'What is 1*5?',
choices : ['10', '1', '5'],
answer : '5'
}
const q4 = {
category : 'MathQ4',
question : 'What is 5/5?',
choices : ['1', '5', '25'],
answer : '1'
}
const q5 = {
category : 'MathQ5',
question : 'What is 5*5?',
choices : ['10', '75', '25'],
answer : '25'
}
const questions = [q1, q2, q3, q4, q5];
const getRandomQuestion = (questions) => {
let randomNum = Math.floor(Math.random()* questions.length)
return questions[randomNum];
}
const getRandomComputerChoice = (choices) => {
let randomNum = Math.floor(Math.random()* choices.length)
return choices[randomNum];
}
const getResults = (q, computer_choice) => {
if(q.answer == computer_choice){
console.log("The computer's choice is correct!");
}
else{
console.log(`The computer's choice is wrong. The correct answer is: ${q.answer}`)
}
}
let question_chosen = getRandomQuestion(questions)
getResults(question_chosen,getRandomComputerChoice(question_chosen.choices))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game