I need to do a simple counter for an IF-ELSE conditional, the question is simple: my code goes through the numbers from 100 to 999 and determines which are of increasing, decreasing and mixed composition.
Example:
creciente=159
decreciente=851
mixto=253
To know this relationship I use an IF-ELSE, what I have to do is an accountant that every time a if
is used, the idea is to build an accumulator each time a specific condition is met, and then use that accumulator and get a percentage of the decreasing and mixed growing numbers.
function DeterminaNumeros(numero) {
var num = numero.toString()
var a = num.split(''); // separa los digitos y los convierte en matriz
for (x = 0; x < a.length; x++) {
}
if (x == 3) {
if (a[0] >= a[1] && a[1] >= a[2]) {
//----------------------------------------------
var acum3 = 1;
var suma = 0;
var valor = 0;
while (acum3 <= 5) {
valor = parseInt(valor);
suma = suma + valor;
acum3 = acum3 + 1;
}
//document.write('decreciente ');
//-------------------------------------------------
} else {
if (a[0] <= a[1] && a[1] <= a[2]) {
document.write('creciente ');
} else {
var acum3 = 0;
document.write('Numero Mixto ');
}
}
}
}
N = 99;
do {
N = N + 1;
var resultado = DeterminaNumeros(N);
document.write(resultado + '<br>');
document.write(N);
} while (N < 1001);