Tell us what’s happening:
hi i know that i haven’t finished yet but am having real problems with the second function, i am confused how to call for the result of the first function and then tell it i want to select from the “choices” available, any hints on what i need to research to come up with the answer greatly recieved
Your code so far
const questions = [
{
catergory: "Photography",
question: "Who took the first successful photograph?",
choices: ["J.M Daguerre", "William Henry Fox Talbot", "Nicephore Niepce"],
answer: "Niecephore Niepce"
},
{
catergory: "Photography",
question: "What year did Kodak introduce Kodachrome color film?",
choices: ["1941", "1933", "1936"],
answer: "1936"
},
{
catergory: "Nature",
question: "What is a young eel called",
choices: ["fry", "sprat", "elver"],
answer: "elver"
},
{
catergory: "Food and Drink",
question: "What fish does caviar come from?",
choices: ["Strugeon", "Salmon", "Shark"],
answer: "Sturgeon"
},
{
catergory: "Nature",
question: "Which bird of prey feeds on small birds?",
choices: ["Osprey", "Golden Eagle", "Sparrow Hawk"],
answer: "Sparrow Hawk"
},
{
catergory: "Food And Drink",
question: "What fish is used to produce Gravadlax?",
choices: ["Sardine", "Eel", "Salmon"],
answer: "Salmon"
}
];
let questionChoice ;
function getRandomQuestion() {
let random = Math.floor(Math.random() * questions.length);
return questions[random].question;
};
function getRandomComputerChoice(choices) {
let random2 = Math.floor(Math.random() * 3);
let randomAnswer = choices[random2];
return randomAnswer;
};
console.log(getRandomQuestion());
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/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Build a Quiz Game - Build a Quiz Game
