<html>
    <head>
        <title>Simple Number Guessing Game: Play Now!</title>
    </head>
    <body>
        <h1>Simple Number Guessing Game</h1>
        <h2>Instructions</h2>
        <p>The goal of this game is to guess the correct number between 1 and 10.</p>
        <script>
            let numberToGuess = Math.floor(Math.random() * 10) + 1;
<pre><code>        // Prompt the user for their guess
        let guess = prompt('What is your guess?');

        // Check if the guess is correct
        if (Number(guess) === numberToGuess) {
            alert('You guessed the correct number! You win!');
        } else {
            alert('Sorry, you guessed the wrong number. Better luck next time!');
        }
    &lt;/script&gt;
&lt;/body&gt;
</code></pre>
</html>
<p>How To Play:</p>
<ol>
<li>Open the HTML page.</li>
<li>Read the instructions.</li>
<li>A prompt window will appear asking for your guess.</li>
<li>Type in a number between 1 and 10.</li>
<li>Submit your guess.</li>
<li>If you guess the correct number, you win! Otherwise, you lose.</li>
</ol>

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

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