Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I am unsure what am I doing wrong with getRandomComputerChoice and getResults

Your code so far

const array = []
let obj1 = {
  category: "PD",
   question: "What is your age?",
    choices: ["12","42","56"],
     answer: "42"
}
let obj2 = {
  category: "PF",
   question: "What is your name?",
    choices: ["Josh","Sandy","Anthony"],
     answer: "Josh"
}
let obj3 = {
  category: "PD",
   question: "What is your sex?",
    choices: ["Male","Female","Trans"],
     answer: "Male"
}
let obj4 = {
  category: "PE",
   question: "What is your work?",
    choices: ["Engineer","Doctor","Lawyer"],
     answer: "Doctor"
}
let obj5 = {
  category: "PZ",
   question: "Where is moon?",
    choices: ["Outside Earth","Near Earth","Inside Earth"],
     answer: "Near Earth"
}
const questions = [obj1,obj2,obj3,obj4,obj5]
console.log(questions)

function getRandomQuestion(arrayQuestions){
  let randomNumber = Math.floor(Math.random() * (4 - 0 + 1)) + 0;
  console.log(randomNumber)
  return arrayQuestions[randomNumber]
}
console.log(getRandomQuestion(questions))

function getRandomComputerChoice(availableChoices){
  let randomNumber = Math.floor(Math.random() * (3 - 0 + 1)) + 0;
  console.log(randomNumber)
  return availableChoices[randomNumber]
}
console.log(getRandomComputerChoice(obj5.choices))
function getResults(questionObj,computerChoice) {
    if (computerChoice == questionObj.answer) {
        return "The computer's choice is correct!";
    }
    else {
        return `The computer's choice is wrong. The correct answer is: ${userAnswer}.}`;
    }
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36

Challenge Information:

Build a Quiz Game - Build a Quiz Game

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md at main · freeCodeCamp/freeCodeCamp · GitHub

userAnswer does not exist inside this function

for getRandomComputerChoice and getRandomQuestion you could also avoid hardcoding the random number range and use the parameter’s length instead