Created
May 18, 2016 00:07
-
-
Save anonymous/0eb97e738470eea4429631c3c5d46c82 to your computer and use it in GitHub Desktop.
Número mágico
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p Adivina el número y colócalo en el campo que se despliega | |
p Coloca cero si deseas salir | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//número máximo | |
var max = 100; | |
//número mínimo | |
var min = 1; | |
// número aleatorio | |
var aleatorio = parseInt(Math.random() * ((max - min) + min)); | |
console.log(aleatorio); | |
var mensaje = "ingresa un número para divinar el número aleatorio" | |
while (true) { | |
var num_user = prompt(mensaje, "0"); | |
num_user = parseInt(num_user); | |
if (num_user === 0) { | |
break; | |
} else if (num_user === aleatorio) | |
alert("Ganaste, has adivinado el número aleatorio"); | |
else if (num_user > aleatorio) { | |
mensaje = "Lo siento, el número aleatorio es menor que el número que ingresaste"; | |
} else if (num_user < aleatorio) { | |
mensaje = "Lo siento, el número aleatorio es mayor que el número que ingresaste" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment