<script>
var systemGuess = Math.floor(Math.random() * 100);
//alert(systemGuess);
while(true){
var userGuess = prompt("Enter your guess between 0 to 100");
userGuess = parseInt(userGuess);
if(systemGuess == userGuess){
alert("Congratulations");
break;
}else if(systemGuess < userGuess){
alert("Please enter lower value");
}else if(systemGuess > userGuess){
alert("Please enter higher value");
}
}
</script>
Demo
var systemGuess = Math.floor(Math.random() * 100);
//alert(systemGuess);
while(true){
var userGuess = prompt("Enter your guess between 0 to 100");
userGuess = parseInt(userGuess);
if(systemGuess == userGuess){
alert("Congratulations");
break;
}else if(systemGuess < userGuess){
alert("Please enter lower value");
}else if(systemGuess > userGuess){
alert("Please enter higher value");
}
}
</script>
0 comments:
Post a Comment