Build a Quiz Game - Build a Quiz Game

Tell us what’s happening:

I can not go through tests 4,9 and 13. Kindy assist

Your code so far

const questions =[
  {category:"Question 1" ,
  question:"What is the capital city of Kenya.",
  choices: ["Mombasa","Nairobi", "Mombasa"],
  answer:"Nairobi" },
  {category: "Question 2",
  question:"What is the capital city of Uganda?",
  choices: ["Jinja","Kampala","Mbarara"],
  answer: "Kampala"},
  {category: "Question 3",
  question:"What is the capital city of Tanzania?",
  choices: ["Dodoma","Dar es Salaam","Tabora"],
  answer: "Dodoma"},
  {category: "Question 4",
  question:"What is the capital city of Sudan?",
  choices: ["Juba","Khartoum","Mbarara"],
  answer: "Khartoum"},
  {
    category: "Question 5",
  question:"What is the capital city of South Africa?",
  choices: ["Cape Town","Johannesburg","Mbarara"],
  answer: "Johannesburg"
  }
];


function getRandomQuestion(questions){
  let randomQuestion= Math.floor(Math.random()*questions.length);
  let questionObject=questions[randomQuestion]
  
  return questionObject
}

function getRandomComputerChoice(choices){
  let randomAnswer=Math.floor(Math.random()*choices.length);
  let computerChoice=questionObject.choices.randomAnswer;
  return computerChoice
  
};

function getResults(questionObject,computerChoice){
  if(questionObject.answer===computerChoice){
    return "The computer's choice is correct!"
  }else if(questionObject.answer!==computerChoice) {
    return `The computer's choice is wrong. The correct answer is:${questionObject.answer}`
  }

}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Build a Quiz Game - Build a Quiz Game

this is not a question

are you sure this is the correct way to get a value using a variable?

check your spacing

How can I go about test 9?

const questions =[
  {category:"Question 1" ,
  question:"What is the capital city of Kenya?",
  choices: ["Mombasa","Nairobi", "Mombasa"],
  answer:"Nairobi" },
  {category: "Question 2",
  question:"What is the capital city of Uganda?",
  choices: ["Jinja","Kampala","Mbarara"],
  answer: "Kampala"},
  {category: "Question 3",
  question:"What is the capital city of Tanzania?",
  choices: ["Dodoma","Dar es Salaam","Tabora"],
  answer: "Dodoma"},
  {category: "Question 4",
  question:"What is the capital city of Sudan?",
  choices: ["Juba","Khartoum","Mbarara"],
  answer: "Khartoum"},
  {
    category: "Question 5",
  question:"What is the capital city of South Africa?",
  choices: ["Cape Town","Johannesburg","Mbarara"],
  answer: "Johannesburg"
  }
];


function getRandomQuestion(questions){
  let randomQuestion= Math.floor(Math.random()*questions.length);
  let questionObject=questions[randomQuestion]
  
  return questionObject
}

function getRandomComputerChoice(choices){
  let randomAnswer=Math.floor(Math.random()*choices.length);
  let computerChoice=choices.randomAnswer;
  return computerChoice
  
};

function getResults(questionObject,computerChoice){
  if(questionObject.answer===computerChoice){
    return "The computer's choice is correct!"
  }else if(questionObject.answer!==computerChoice) {
    return `The computer's choice is wrong. The correct answer is: ${questionObject.answer}`
  }

}

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

this is also not the way to use a variable to access a value in an array or object, please review that