Skip to content

Commit efc71b2

Browse files
committed
Add sum validation for credit card number to ensure it exceeds 16
1 parent c9ffb46 commit efc71b2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎sprint-3-stretch-exercises/card-validator.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ function isValidCreditCardNumber(cardNumber){
2626
if(lastDigit % 2 !== 0) {
2727
return false;
2828
}
29+
30+
let sum = 0;
31+
for(let i = 0; i < cardNumber.length; i++){
32+
sum += Number(cardNumber[i]);
33+
}
34+
if(sum <= 16){
35+
return false;
36+
}
2937
}

0 commit comments

Comments
 (0)