Skip to content

Tarjeta de crédito#32

Open
ruthmz wants to merge 1 commit intoLaboratoria-learning:masterfrom
ruthmz:master
Open

Tarjeta de crédito#32
ruthmz wants to merge 1 commit intoLaboratoria-learning:masterfrom
ruthmz:master

Conversation

@ruthmz
Copy link

@ruthmz ruthmz commented Nov 4, 2017

No description provided.

@cureForMi
Copy link

@diegovelezg este pull request pasa.

@@ -0,0 +1,23 @@

function isValidCard(cardNumber) {
var string = cardNumber.toString();
Copy link

Choose a reason for hiding this comment

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

nit: string es un nombre muy genérico para tu variable, quizá cardNumberString queda mejor?

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) {
Copy link

Choose a reason for hiding this comment

The 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 for.

var cardlength = string.length;
var sum = 0;
for (var i = 0; i < cardlength; i = i + 2) {
var numbers = (string.charAt(i)) * 2;
Copy link

Choose a reason for hiding this comment

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

nit: numbers en realidad contiene un sólo número, sería mejor llamarlo number.

@perezju perezju removed their assignment Dec 22, 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.

4 participants