<!DOCTYPE html>
<html>
<head>
	<title>Simple HTML Guessing Game</title>
</head>
<body>
	<h1>Guess the Number</h1>
	<p>I'm thinking of a number between 1 and 10. Can you guess it?</p>
	<script>
		// Generate a random number between 1 and 10
		let randomNumber = Math.floor(Math.random() * 10) + 1;
<pre><code>	// Ask user for a guess
	let guess = prompt('Guess a number between 1 and 10');

	// Check if the guess is correct
	if(parseInt(guess) === randomNumber) {
		alert('You guessed the number! You win!');
	} else {
		alert('Sorry, the number was ' + randomNumber);
	}
&lt;/script&gt;
</code></pre>
</body>
</html>
Simple HTML Guessing Game - Play Now!

原文地址: https://www.cveoy.top/t/topic/lmlK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录