Simple HTML Guessing Game - Try Your Luck!
<html>
<head>
<title>Guess the Number Game</title>
<script>
// Generate a random number between 1 and 10
let secretNumber = Math.floor(Math.random() * 10) + 1;
<pre><code>// Ask the user to guess the number
let guess = prompt('Guess a number between 1 and 10');
// Check if the user guessed the number
if (parseInt(guess) === secretNumber) {
alert('You guessed the number!');
} else {
alert('Sorry, that was not the number. The number was ' + secretNumber);
}
</code></pre>
</script>
</head>
<body>
<h1>Guess the Number Game</h1>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lmcR 著作权归作者所有。请勿转载和采集!