I need to find the maximum and minimum of a sequence of numbers that the user enters, at random, until he wants to. I mean, it could be 2 numbers like 356, if you want to.
I can only use while and if, and not for.
So far I have this:
var seguir;
var numero;
var maximo;
var minimo;
do {
numero = parseInt(prompt("Ingrese numero"));
while (isNaN(numero)) {
numero = parseInt(prompt("Error. Ingrese numero"));
}
if (numero < minimo) {
minimo = numero;
}
if (numero > maximo){
maximo = numero;
}
seguir = confirm("Desea continuar?");
}
while (seguir);
console.log("max: " + maximo + " Minimo: " + minimo)
But it only shows undefined
.
Thank you very much.