let numeroUsuario ; let numeroSecreto; let intentos = 1; let rangoMax = 0; let maxIntentos;
rangoMax = parseInt(prompt(Ingrese el limite maximo para jugar:
));
maxIntentos = parseInt(prompt(Ingrese el limite maximo de intentos para jugar:
));
numeroSecreto = Math.floor(Math.random()*rangoMax) + 1;
console.log(numeroSecreto);
while(numeroSecreto != numeroUsuario){
numeroUsuario=parseInt(prompt(Ingrese un numero por favor entre 1 y ${rangoMax}
));
if(numeroSecreto == numeroUsuario ){
alert(Acertaste el numero secreto es: ${numeroSecreto}. Lo hiciste en ${intentos} ${intentos == 1 ? 'vez': 'veces'}
);
}else{
if(numeroSecreto > numeroUsuario){
alert('El numero secreto es mayor! ');
}else{
alert('El numero secreto es menor');
}
intentos++;
if( intentos > maxIntentos ){
alert(Llegaste al limite de intentos ${maxIntentos}
);
break;
}
}
}