-
Notifications
You must be signed in to change notification settings - Fork 105
Función Card Validation de María Alejandra Cabrera Pérez #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlejandraCP
wants to merge
1
commit into
Laboratoria-learning:master
Choose a base branch
from
AlejandraCP:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "parserOptions": { | ||
| "ecmaVersion": 6 | ||
| }, | ||
| "rules": { | ||
| "keyword-spacing": 1, | ||
| "space-before-function-paren": [1, "never"], | ||
| "eqeqeq": 1, | ||
| "space-infix-ops": 1, | ||
| "comma-spacing": 1, | ||
| "brace-style": 1, | ||
| "no-multiple-empty-lines": 1, | ||
| "camelcase": 1, | ||
| "func-call-spacing": 1, | ||
| "key-spacing": 1, | ||
| "semi": 1, | ||
| "no-floating-decimal": 1, | ||
| "no-multi-spaces": 1, | ||
| "object-property-newline": 1, | ||
| "padded-blocks": [1, "never"], | ||
| "space-before-blocks": 1, | ||
| "space-in-parens": 1, | ||
| "spaced-comment": 1, | ||
| "quotes": [1, "single"], | ||
| "id-length": [1, { "exceptions": ["i", "j", "x"] }], | ||
| "indent": [1, 2], | ||
| "no-array-constructor": 1 | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| Funcion variable_de_retorno <- isValidCard ( ) | ||
| sum<-0 | ||
| Escribir numberCard | ||
| Repetir | ||
| Leer numberCard | ||
| Para i<-0 Hasta numberCard.length Con Paso 1 Hacer | ||
| Si (numberCard[i]=' ' o isNaN(numberCard[i])) Entonces | ||
| Escribir numberCard | ||
| Fin Si | ||
| Fin Para | ||
| Hasta Que (numberCard.length <16 o numberCard.length >16) | ||
| Para j<-0 Hasta numberCard.length Con Paso 1 Hacer | ||
| charValue<-parseInt(numberCard[j]) | ||
| Si j%2<-0 Entonces | ||
| sum<-sum + charValue | ||
| Fin Si | ||
| Si j%2<>0 Entonces | ||
| Si ((charValue*2)<=9) Entonces | ||
| sum<-sum + (charValue*2) | ||
| Fin Si | ||
| Si ((charValue * 2) > 9) Entonces | ||
| twoDigits<-charValue*2.toString | ||
| sumDigits<-parseInt(twoDigits[0]) + parseInt(twoDigits[1]); | ||
| sum<-sum+sumDigits | ||
| Fin Si | ||
| Fin Si | ||
| Fin Para | ||
| Si sum%10<-0 Entonces | ||
| Leer "El n�mero de su tarjeta es valido" | ||
| SiNo | ||
| Escribir document.getElementById("demo").innerHTML =("El n�mero de su tarjeta es inv�lido") | ||
| Fin Si | ||
| Fin Funcion | ||
| Algoritmo tarjeta_de_credito | ||
|
|
||
| FinAlgoritmo |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset='utf-8'> | ||
| <title>Validación de número de tarjeta</title> | ||
| <style type='text/css'> | ||
| body { | ||
| background-color: #F2F2F2; | ||
| } | ||
| h1 { | ||
| font-size: 50px; | ||
| color: #0489B1; | ||
| } | ||
| p { | ||
| font-size: 25px; | ||
| color: #151515; | ||
| } | ||
| button { | ||
| font-size: 14px; | ||
| border-radius: 9px; | ||
| } | ||
|
|
||
| </style> | ||
| </head> | ||
| <body> | ||
| <h1 align=center >Validador de número de tarjeta</h1> | ||
| <div> | ||
| <p>¿Desea saber si el número de su tarjeta es válida?</p> | ||
| <button onclick="isValidCard()">Click aquí</button> | ||
| <p id="demo"></p> | ||
| </div> | ||
| <script type="text/javascript" src='js/app.js'> | ||
| </script> | ||
| </body> | ||
| </html> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Verifica si el número de tarjeta es válido. | ||
| function isValidCard() { | ||
| // Almacena sumatoria de los dígitos. | ||
| var sum = 0; | ||
| var numberCard; | ||
|
|
||
| // Hacer al menos una ves, si numberCard tiene más o menos de 16 elementos. | ||
| do { | ||
| // Los dígitos obtenidos son separados en un array y el orden es invertido. | ||
| numberCard = prompt('Escribe el número de tu tarjeta').split('').reverse(); | ||
|
|
||
| // Ciclo que itera por cada elemento del array numberCard. | ||
| for (var i = 0; i < numberCard.length; i++) { | ||
| // Si el elemento es igual a un string vacio aparece nuevo prompt. | ||
| // Si el elemento es NaN aparece nuevo prompt. | ||
| if (numberCard[i] === ' ' || isNaN(numberCard[i])) { | ||
| numberCard = prompt('No coloque espacios vacíos o letras, \n vuelve a escribir el número de tu tarjeta. ').split('').reverse(); | ||
| } | ||
| } | ||
| } while (numberCard.length < 16 || numberCard.length > 16); | ||
|
|
||
| for (var j = 0; j < numberCard.length; j++) { | ||
| // Convierte (parsea) una cadena y devuelve un entero de la base decimal. | ||
| var charValue = parseInt(numberCard[j]); | ||
|
|
||
| // Si el índice del elemento es par, adiciona su valor a sum. | ||
| if (j % 2 === 0) { | ||
| sum += charValue; | ||
| } | ||
|
|
||
| // Si el índice del elemento es impar, el elemento se multiplica por 2. | ||
| if (j % 2 !== 0) { | ||
| // Si el producto es menor a 9, se adiciona a sum. | ||
| if ((charValue * 2) <= 9) { | ||
| sum += (charValue * 2); | ||
| } | ||
|
|
||
| // Si el producto es mayor a 9, se separan los dígitos del producto y se suman. | ||
| if ((charValue * 2) > 9) { | ||
| // El producto se convierte a string para separar los dígitos. | ||
| var twoDigits = (charValue * 2).toString(); | ||
| var sumDigits = parseInt(twoDigits[0]) + parseInt(twoDigits[1]); | ||
| sum += sumDigits; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Si el residuo se sum entre 10 es cero, el número de tarjeta es válido. | ||
| // Si el residuo se sum entre 10 no es cero, el número de tarjeta no es válido. | ||
| if (sum % 10 === 0) { | ||
| document.getElementById('demo').innerHTML = 'El número de su tarjeta es valido'; | ||
| } else | ||
| document.getElementById('demo').innerHTML = 'El número de su tarjeta es inválido'; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es buen idea verificar que es un numero y esto cubre casi todos los casos, pero todavia permite "+" y "-" porque "-9" es un numero.