Skip to content

akshhattt/JavaScript-quiz-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Quiz Game

Overview

JavaScript Quiz Game is a simple web-based quiz game built using HTML, CSS, and JavaScript. The game presents multiple-choice questions to the user, allows them to select their answers, and calculates their score at the end.

Project Structure

📂 javascript_quiz_game
    📂 css
        📄 styles.css
    📂 js
        📄 quiz.js
    📄 index.html
    📄 README.md
  

Getting Started

Prerequisites

To run the JavaScript quiz game locally, you need a web browser with JavaScript enabled.

Installation

  1. Clone the repository to your local machine:
  2. git clone https://github.com/akshhattt/Javascript-quiz-game.git
        
  3. Open the index.html file in your web browser.

Usage

  1. You will see multiple-choice questions displayed on the web page.
  2. Select the correct answer for each question.
  3. Click the "Submit Answers" button to see your score.

Adding/Removing Questions

To add or remove questions from the quiz game, follow these steps:

  1. Open the index.html file in a text editor.
  2. Copy one of the existing question divs (e.g., <div class="question">...</div>).
  3. Paste the copied div below the last question div and modify the question and answer options accordingly.
  4. To remove a question, simply delete its corresponding question div.

Customizing Correct Answers

To customize correct answers for each question, open the quiz.js file in a text editor and locate the getCorrectAnswer() function. Update the switch statement with the correct answers for each question.

function getCorrectAnswer(questionNumber) {
  switch (questionNumber) {
    case 1:
      return "a"; // Correct answer for Question 1
    case 2:
      return "b"; // Correct answer for Question 2
    // Add more cases for additional questions as needed
    default:
      return "a"; // Default to "a" for any unknown question
  }
}
  

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • This project is part of my learning journey to improve my JavaScript skills.

About

The JavaScript Quiz Game is a fun and interactive web-based quiz application built using HTML, CSS, and JavaScript. It presents users with multiple-choice questions and allows them to select their answers. After answering all the questions, users can submit their choices to see their score

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors