Skip to content

Commit c9ffb46

Browse files
committed
Add validation for last digit of credit card number to ensure it's even
1 parent e976f4b commit c9ffb46

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ function isValidCreditCardNumber(cardNumber){
2121
if(foundDifferentDigit === false){
2222
return false;
2323
}
24+
25+
const lastDigit = Number(cardNumber[15]);
26+
if(lastDigit % 2 !== 0) {
27+
return false;
28+
}
2429
}

0 commit comments

Comments
 (0)