-
Notifications
You must be signed in to change notification settings - Fork 105
Tarjeta de crédito #32
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
|
|
||
| function isValidCard(cardNumber) { | ||
| var string = cardNumber.toString(); | ||
| cardNumber !== undefined; | ||
| cardNumber === parseInt(prompt('Ingrese el número de su tarjeta de crédito')); | ||
| var cardlength = string.length; | ||
| var sum = 0; | ||
| for (var i = 0; i < cardlength; i = i + 2) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. los dígitos se deben contar de derecha a izquierda, para corregirlo habría que invertir la cadena antes de empezar los ciclos |
||
| var numbers = (string.charAt(i)) * 2; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
| if (numbers >= 10) { | ||
| var numbersCard = numbers.toString(); | ||
| numbers = (numbersCard.charAt(0)) + (numbersCard.charAt(1)); | ||
| } | ||
| sum = sum + numbers; | ||
| } for (var j = 1; j < cardlength; j = j + 2) { | ||
| sum = sum + (string.charAt(i)); | ||
| } | ||
| if (sum % 10 === 0) { | ||
| alert('Has ingresado un número de tarjeta correcto'); | ||
| } else { | ||
| alert('Has ingresado un número de tarjeta incorrecto'); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title></title> | ||
| </head> | ||
| <body> | ||
| <script type="text/javascript" src="app.js"> | ||
|
|
||
| </script> | ||
| </body> | ||
| </html> |
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.
nit:
stringes un nombre muy genérico para tu variable, quizácardNumberStringqueda mejor?