Skip to content

Commit 6fcb856

Browse files
committed
Simplify digit sum check by returning boolean expression directly
1 parent 93ae4e9 commit 6fcb856

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Sprint-3/3-stretch/password-validator.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ function isValidCreditCard(cardNumber) {
1717

1818
// Calculate the sum of all digits and check if greater than 16
1919
const sum = cardNumber.split('').reduce((acc, digit) => acc + Number(digit), 0);
20-
if (sum <= 16) {
21-
return false;
22-
}
20+
return sum <= 16;
2321

2422
// All conditions passed, card is valid
2523
return true;

0 commit comments

Comments
 (0)