Ejercicio de Tarjeta de credito#54
Open
Priscilarojas wants to merge 2 commits intoLaboratoria-learning:masterfrom
Open
Ejercicio de Tarjeta de credito#54Priscilarojas wants to merge 2 commits intoLaboratoria-learning:masterfrom
Priscilarojas wants to merge 2 commits intoLaboratoria-learning:masterfrom
Conversation
cm6n
requested changes
Dec 27, 2017
| <title></title> | ||
| </head> | ||
| <body> | ||
| <script type= tarjeta de credito/javascript" src="app.js"> |
| } | ||
|
|
||
| var count = impair + smallNumbers + sumOfLarge; | ||
| if (cardNumber === '' || cardNumber !== Number) { |
There was a problem hiding this comment.
"cardNumber !== Number" no sirve para verificar que el string solo contiene digitos. Podrias hacer on for loop y verificar que cada character es un digito.
| for (j = 0; j < array.length; j++) {// invertir los elementos del array | ||
| var item = array.pop(); | ||
| array.splice(j, 0, item); | ||
| } |
There was a problem hiding this comment.
las listas y arrays tienen un método 'reverse'
| var newArray = []; // variable donde se almacenara los numeros de uno en uno //4088521938925895 | ||
| for (k = 0; k < array.length; k++) { | ||
| newArray.push(parseInt(array[k])); // newArray[5, 9, 8, 5, 2, 9, 8, 3, 9, 1, 2, 5, 8, 8, 0, 4] | ||
| } |
There was a problem hiding this comment.
No hace falta crear newArray dos veces (?)
| } | ||
| // separando numeros pares de impares | ||
| var pair = []; // numeros pares | ||
| var impair = 0; // numeros impares // 47 |
| var smallNumbers = 0; // numeros menores que 10 | ||
| var bigNumbers = []; // numeros mayores que 10 | ||
| for (p = 0; p < pair.length; p++) { | ||
| if (pair[p] <= 10) { |
| if (pair[p] <= 10) { | ||
| smallNumbers += (pair[p]); | ||
| } else { | ||
| bigNumbers.push(pair[p]); // [ 10, 18 ] |
There was a problem hiding this comment.
Tal vez seria mas facil sumar los bigNumbers aqui. Es util notar que un numero como 13 se puede separar restando 10.
13 - 10 = 3 (el digito menor)
1 + 3 = 4 (suma de los digitos)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.