Este es version del juego de adivinición de un numero ingresado por el usuario y con tres intentos para adivinar.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adivina el numero </title>
</head>
<h1>ADIVINAR EL NUMERO: </h1>
<body>
<script>
var numPredictivo = Math.round(Math.random()*10);
var intentos = 3;
var contador = 1;
while (contador <= intentos){
var numeroUsr = parseInt(prompt("Introduce un número"));
if (numeroUsr == numPredictivo ){
alert("Correcto el numero era el "+numPredictivo);
break;
}
else {
alert("Incorrecto");
}
contador++;
}
document.write("este es el numero que el programa genero para usted " +numPredictivo)
</script>
</body>
</html>