-
Notifications
You must be signed in to change notification settings - Fork 105
Enviando proyecto valid-Credit-Card #56
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 |
|---|---|---|
| @@ -1,38 +1,26 @@ | ||
| # Tarjeta de crédito válida | ||
|
|
||
| Crea una web que pida, por medio de un `prompt()`, el número de una tarjeta de | ||
| crédito y confirme su validez según el [algoritmo de Luhn](https://es.wikipedia.org/wiki/Algoritmo_de_Luhn). | ||
| Lee este blog que explica [cómo funciona el algoritmo de Luhn](http://www.quobit.mx/asi-funciona-el-algoritmo-de-luhn-para-generar-numeros-de-tarjetas-de-credito.html). | ||
|
|
||
| ## Entregables | ||
|
|
||
| Para cada producto debes entregar **un repositorio de GitHub** que | ||
| contenga: | ||
| 1. Archivo `README.md` que explique el **pseudocódigo** de tu solución y su | ||
| **diagrama de flujo** | ||
| 2. Archivo `app.js` con el **código** de tu solución | ||
| 3. Archivo `index.html` vinculado con tu `app.js` | ||
|
|
||
| ## Tips | ||
|
|
||
| A continuación un video de Michelle que te lleva a través del algoritmo de | ||
| Luhn y te da tips para completar este proyecto: | ||
|
|
||
| [](https://www.youtube.com/watch?v=f0zL6Ot9y_w) | ||
|
|
||
| ## Consideraciones específicas | ||
|
|
||
| 1. Tu código debe estar compuesto por 1 función: `isValidCard` | ||
| 2. El usuario no debe poder ingresar un campo vacío | ||
|
|
||
| ## Criterios de evaluación | ||
|
|
||
| Se tomarán en cuenta las siguientes consideraciones a la hora de evaluar tu solución: | ||
|
|
||
| 1. Nombramiento de variables | ||
| 2. Indentación | ||
| 3. Validación de input: el usuario no debe poder ingresar un campo vacío o de tipo que no corresponda | ||
| 4. Estructura de tus archivos | ||
| 5. Archivo `README.md` correctamente redactado | ||
| 6. Uso de comentarios para hacer tu código más legible | ||
| 7. Que el programa cumpla con el propósito requerido | ||
| # Pseudocodigo isValidCard | ||
| * function isValidCard(cardNumber) | ||
| * Repetir | ||
| * mensajecardNumber = 'Ingrese el número de la tarjeta de crédito a validar'; | ||
| * hasta ((cardNumber.length) <= 0); | ||
| * reverseCardNumber = cardNumber.split('').reverse().map(Number); | ||
| * Leer sumArrayElements = '' | ||
| * Leer message = ''; | ||
| * Para ( i = 1; i < reverseCardNumber.length; i = i + 2) | ||
| * reverseCardNumber[i] = reverseCardNumber[i] * 2; | ||
| * if (reverseCardNumber[i] >= 10) entonces | ||
| * separatedDigits = reverseCardNumber[i].toString().split('').map(Number); | ||
| * reverseCardNumber[i] = (separatedDigits[0] + * separatedDigits[1]); | ||
| * fin si | ||
| Leer sumArrayElements += reverseCardNumber[i]; | ||
| * Fin para | ||
| * si (sumArrayElements % 10 === 0) entonces | ||
| * escribir message = 'valido' | ||
| * si no | ||
| * escribir message = 'invalido'; | ||
| * mostrar message; | ||
| * Fin funcion | ||
| # Diagrama de Flujo | ||
|  | ||
| ## webSite | ||
| * Puede ver el [Proyecto en vivo](https://jennifercarmen.github.io/valid-credit-card/) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <html> | ||
| <head> | ||
| <title>Validando Tarjeta de credito</title> | ||
| </head> | ||
| <body> | ||
| <script src="js/app.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Funcion valida tarjeta de credito | ||
| function isValidCard(cardNumber) { | ||
| // validar que el usuario ingrese el numero de tarjeta | ||
| do { | ||
| var cardNumber = prompt('Ingrese el numero de la tarjeta de credito a validar(13Digitos)'); | ||
| // Agregamos los numeros de la tarjeta a un array en orden inverso y convertimos a cada elemento en tipo numerico | ||
| } while ((cardNumber.length <= 12 || cardNumber.length >= 14));var reverseCardNumber = cardNumber.split('').reverse().map(Number); | ||
| var sumArrayElements = ''; | ||
|
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. sumArrayElements debe tener un valor inicial de = 0 porque es tipo Number. var x = ''; |
||
| var message = ''; | ||
| // buscar cada elemento par del array y multiplicar por 2 | ||
| for (var i = 1; i < reverseCardNumber.length; i = i + 2) { | ||
| reverseCardNumber[i] = reverseCardNumber[i] * 2; | ||
| if (reverseCardNumber[i] >= 10) { | ||
| // convierte el numero en string, se separa los digitos del numero y convierte en numericos | ||
| var separatedDigits = reverseCardNumber[i].toString().split('').map(Number); | ||
| // suma los dos digitos del elemento separado en dos cifras | ||
| reverseCardNumber[i] = (separatedDigits[0] + separatedDigits[1]); | ||
| } | ||
| // obtiene la suma total del array | ||
|
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. Esto solo suma los digitos pares porque este for is solo para "i=i+2". Agrega otra for para sumar? |
||
| sumArrayElements += reverseCardNumber[i]; | ||
| } | ||
| // devuelve mensaje al usuario | ||
| (sumArrayElements % 10 === 0) ? message = 'El numero de tarjeta es valido' : message = 'El numero de tarjeta es invalido'; | ||
| return alert(message); | ||
| } | ||
| // llama a la funcion | ||
| isValidCard(); | ||
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.
Por favor ponga "var reverseCardNumber ..." en su propia linea.