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.
📂 javascript_quiz_game
📂 css
📄 styles.css
📂 js
📄 quiz.js
📄 index.html
📄 README.md
To run the JavaScript quiz game locally, you need a web browser with JavaScript enabled.
- Clone the repository to your local machine:
- Open the
index.htmlfile in your web browser.
git clone https://github.com/akshhattt/Javascript-quiz-game.git
- You will see multiple-choice questions displayed on the web page.
- Select the correct answer for each question.
- Click the "Submit Answers" button to see your score.
To add or remove questions from the quiz game, follow these steps:
- Open the
index.htmlfile in a text editor. - Copy one of the existing question divs (e.g.,
<div class="question">...</div>). - Paste the copied div below the last question div and modify the question and answer options accordingly.
- To remove a question, simply delete its corresponding question div.
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
}
}
This project is licensed under the MIT License - see the LICENSE file for details.
- This project is part of my learning journey to improve my JavaScript skills.