-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (34 loc) · 2.09 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//alert("estoy aqui"); Comprobando conexion con javascript
//function isValidCard(numero_tarjeta){
var tarjetaIngresadaUsuario = prompt("Indique los digitos de su tarjeta. 16 dígitos");
var cantidadCaracteres = tarjetaIngresadaUsuario.length;
//Comenzando a aplicar Algoritmo Luhn. Recorrer dato
for (var i = 0; i < cantidadCaracteres; i++) {
/*var msg = "iteracion: " + i + "</br>";
document.write(msg); (comprobando que el for corre)*/
//recorrer cada caracter para par o impar (x2)
var caracter = parseInt(tarjetaIngresadaUsuario.charAt(i));
/*var msg = "caracter: " + caracter + "</br>";
document.write(msg); (comprobando que variable caracter corre)*/
//Buscando pares
var tipo = (caracter%2)?"par":"impar";
/*var msg = "caracter: " + caracter + " es: " + tipo +"</br>";
document.write(msg); (comprobando que variable tipo corre) */
if (tipo == "par") {
var msg = "caracter: " + caracter + " es: " + tipo +"</br>";
document.write(msg); //Comprobando si el if corre)
//
var parPorDos = caracter * 2;
// Para validar si var parPorDos es mayor o igual 10
if (parPorDos >=10){
}
/*Paso 1 Luhn: El primer paso es tomar
todos los números en posiciones pares y multiplicarlos por 2*/
//pares[i] = parPordos;
/* -----------------------------------------------------------
Hasta aquí llego mi código que compila, los demás intentos
me bloqueaban el desarrollo del codigo anterior
------------------------------------------------------------*/
}
}
//function isValidCard(numero_tarjeta){