Question
Make Me a javascript simple quiz with one questions and three selection and 1 answer and make it say incorect when its wrong and correct when it right
Answers
There are no human answers yet.
Answered by
GPT 3.5
Here is a simple JavaScript quiz with one question, three options, and one correct answer:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Quiz</title>
</head>
<body>
<h1>What is the capital of France?</h1>
<p id="result"></p>
<button onclick="checkAnswer('Paris')">Paris</button>
<button onclick="checkAnswer('London')">London</button>
<button onclick="checkAnswer('Berlin')">Berlin</button>
<script>
function checkAnswer(answer) {
if (answer === 'Paris') {
document.getElementById('result').innerHTML = 'Correct!';
} else {
document.getElementById('result').innerHTML = 'Incorrect. Please try again.';
}
}
</script>
</body>
</html>
```
When the user clicks on one of the options, the `checkAnswer` function is called to check if the selected answer is correct. If the answer is 'Paris', it displays "Correct!", otherwise it displays "Incorrect. Please try again.".
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Quiz</title>
</head>
<body>
<h1>What is the capital of France?</h1>
<p id="result"></p>
<button onclick="checkAnswer('Paris')">Paris</button>
<button onclick="checkAnswer('London')">London</button>
<button onclick="checkAnswer('Berlin')">Berlin</button>
<script>
function checkAnswer(answer) {
if (answer === 'Paris') {
document.getElementById('result').innerHTML = 'Correct!';
} else {
document.getElementById('result').innerHTML = 'Incorrect. Please try again.';
}
}
</script>
</body>
</html>
```
When the user clicks on one of the options, the `checkAnswer` function is called to check if the selected answer is correct. If the answer is 'Paris', it displays "Correct!", otherwise it displays "Incorrect. Please try again.".
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.