Untitled
// Assuming you have an array of questions and answers var questions = ["Question 1", "Question 2", ...]; var answers = ["Answer 1", "Answer 2", ...]; // Function to display a random question function displayQuestion() { var randomIndex = Math.floor(Math.random() * questions.length); // Display the question and answer options } // Function to check the user's answer function checkAnswer(userAnswer) { // Compare userAnswer with the correct answer if (userAnswer === answers[randomIndex]) { // Display the "Winning" message } else { // Display the "Trying again" message } }
Leave a Comment