Created
January 21, 2022 05:41
-
-
Save navarroaxel/5fdeef97fcd6c5f2de290b2558a2f74b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getDv(partida) { | |
| partida = new String(partida); | |
| var a = new Array(7); | |
| var i; | |
| for (i = 0; i < 7; a[i++] = "0"); // cargo el arreglo con ceros | |
| for (i = partida.length - 1, j = 0; i >= 0; i--, j++) | |
| a[a.length - 1 - j] = partida.charAt(i);// el array esta en sentido inverso | |
| var dv = new String((a[6] * 7 + a[5] * 6 + a[4] * 5 + a[3] * 4 + a[2] * 3 + a[1] * 2 + a[0] * 7) % 11); | |
| if (dv == "10") | |
| dv = "1"; | |
| longitud_digito = 2; | |
| if (dv.length < longitud_digito) { | |
| var x = new String(); | |
| for (i = dv.length; i < longitud_digito; i++) | |
| x = x + "0"; | |
| dv = x + dv; | |
| } | |
| return parseInt(dv); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment