Simple HTML Guessing Game: Code and Tutorial
<html>
<head>
<title>Guess the Number Game</title>
<script type='text/javascript'>
var randomNumber = Math.floor(Math.random() * 10) + 1;
var guess = prompt('Guess a number between 1 and 10');
if (parseInt(guess) === randomNumber) {
document.write('You guessed the number!');
} else {
document.write('Sorry, the number was ' + randomNumber);
}
</script>
</head>
<body>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lmjW 著作权归作者所有。请勿转载和采集!