Skip to content

Ejercicio de Tarjeta de credito#54

Open
Priscilarojas wants to merge 2 commits intoLaboratoria-learning:masterfrom
Priscilarojas:master
Open

Ejercicio de Tarjeta de credito#54
Priscilarojas wants to merge 2 commits intoLaboratoria-learning:masterfrom
Priscilarojas:master

Conversation

@Priscilarojas
Copy link

No description provided.

<title></title>
</head>
<body>
<script type= tarjeta de credito/javascript" src="app.js">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type="text/javascript" ?

}

var count = impair + smallNumbers + sumOfLarge;
if (cardNumber === '' || cardNumber !== Number) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hace falta crear newArray dos veces (?)

}
// separando numeros pares de impares
var pair = []; // numeros pares
var impair = 0; // numeros impares // 47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

se dice "even" (par) y "odd" (impar)

var smallNumbers = 0; // numeros menores que 10
var bigNumbers = []; // numeros mayores que 10
for (p = 0; p < pair.length; p++) {
if (pair[p] <= 10) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< 10

if (pair[p] <= 10) {
smallNumbers += (pair[p]);
} else {
bigNumbers.push(pair[p]); // [ 10, 18 ]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@cm6n cm6n removed their assignment Dec 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants