<html>
<head>
  <title>Simple HTML Guessing Game</title>
</head>
<body>
  <h1>Welcome to the Simple HTML Guessing Game!</h1>
  <div>
    <p>
      You have 3 lives. Your goal is to complete the game without losing all your lives.
    </p>
  </div>
  <script>
    var lives = 3;

    function guessNumber() {
      var number = Math.floor(Math.random() * 10);
      var guess = prompt('Guess a number between 0 and 10:');

      if (parseInt(guess) === number) {
        alert('You guessed correct!');
      } else {
        alert('You guessed wrong!');
        lives--;
      }

      if (lives > 0) {
        guessNumber();
      } else {
        alert('You lost all your lives!');
      }
    }

    guessNumber();
  </script>
</body>
</html>
Simple HTML Guessing Game - Play Now!

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

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