Guess Game
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Guess Game</title>
</head>
<body>
<h1>User Enter's a max number<br>A random number is generated from 1 to max <br>User need to guess the random number using the hints</h1>
<script src="GuessGame.js"></script>
</body>
</html>
CSS
const max=prompt("Enter the max number:");
const random=Math.floor(Math.random()*max)+1;
let guess=prompt("Guess the number:");
while(true){
if(guess=="quit"){
console.log("User Quits...");
break;
}
else if(guess==random){
console.log("You Guessed it right! THe random number is:",random);
break;
}
else if(guess<random){
guess=prompt("Your Guess is too small...Try Again");
}
else{guess=prompt("Your guess is too large!!Try Again");
}
}
Comments
Post a Comment