Skip to content

Latest commit

 

History

History
71 lines (62 loc) · 2.49 KB

File metadata and controls

71 lines (62 loc) · 2.49 KB

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.