Simple HTML Game: Play Now and Test Your Knowledge
<html>
<head>
<title>Simple HTML Game: Test Your Knowledge</title>
</head>
<body>
<h1>Simple HTML Trivia Game</h1>
<p>Click the button below to start the game and test your knowledge.</p>
<p><button onclick="startGame()">Start Game</button></p>
<script>
function startGame() {
alert('You are about to start a simple HTML game. Good luck!');
let score = 0;
let answer1 = prompt('What is the capital of France?');
if (answer1.toUpperCase() === 'PARIS') {
score++;
alert('Correct! Your score is now ' + score);
} else {
alert('Incorrect! Your score is still ' + score);
}
let answer2 = prompt('What is the capital of Italy?');
if (answer2.toUpperCase() === 'ROME') {
score++;
alert('Correct! Your score is now ' + score);
} else {
alert('Incorrect! Your score is still ' + score);
}
alert('Game Over! You got a score of ' + score);
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lntE 著作权归作者所有。请勿转载和采集!