generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LON | Amirhossein Aminian | Module-structuring-and-testing-data | sprint3 #142
Open
AmirhosseinAminian
wants to merge
38
commits into
CodeYourFuture:main
Choose a base branch
from
AmirhosseinAminian:amiraminia/sprint3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a9422f3
get-angle
AmirhosseinAminian fcbc6ce
get-card-value
AmirhosseinAminian c4029b3
fraction
AmirhosseinAminian 73fb2ad
valid-triangle
AmirhosseinAminian 5f53537
rotate-chart
AmirhosseinAminian 22b26ab
credit_card_number
AmirhosseinAminian d0f894d
count_char
AmirhosseinAminian a04f883
ordinal_number-test
AmirhosseinAminian 37c799f
Fixing feedback
AmirhosseinAminian 3a19cbb
is_prime
AmirhosseinAminian 9617648
feedback
AmirhosseinAminian 048a134
password_validation
AmirhosseinAminian 7f4fdbe
repeat_test
AmirhosseinAminian 0696a5a
find.js
AmirhosseinAminian bf0c3b5
find.js
AmirhosseinAminian bb8e1c8
Merge branch 'main' into amiraminia/sprint3
SallyMcGrath 2ce2bba
java to javascript
AmirhosseinAminian 004e0ec
Merge branch 'amiraminia/sprint3' of https://github.com/Amir200524/Mo…
AmirhosseinAminian 6d213de
java to javascript
AmirhosseinAminian b402751
java to javascript
AmirhosseinAminian e964339
converting to JavaScript
AmirhosseinAminian c970c82
more test case
AmirhosseinAminian fd5fd05
jest test
AmirhosseinAminian e480c7d
deleted example file
AmirhosseinAminian 9423d02
generating test.js
AmirhosseinAminian b5dd0e1
fixing feedback
AmirhosseinAminian 2160580
fixing password.test
AmirhosseinAminian 6fbaaa4
generating count.test
AmirhosseinAminian e8ae613
generating get-ordinalnumber.test
AmirhosseinAminian e54439f
generating password-validator.test
AmirhosseinAminian e112659
generating repeat.test
AmirhosseinAminian 9507417
fixing code
AmirhosseinAminian acf58fb
fixing repeat.test & repeat.js
AmirhosseinAminian 67e8477
test of number of digits is exactly 16
AmirhosseinAminian b71f5a4
generate ifs for special case and skip even numbers
AmirhosseinAminian c88ad5f
export previousPasswords
AmirhosseinAminian b547b6c
Handles the special case & Eliminates even numbers
AmirhosseinAminian 4018a61
Shift Normalization
AmirhosseinAminian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
credit_card_number
- Loading branch information
commit 22b26ab7e227e72e22d58f14a7131116f08f44b2
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function validateCreditCard(cardNumber) { | ||
if (typeof cardNumber !== 'string' || cardNumber.length !== 16 || !/^\d{16}$/.test(cardNumber)) { | ||
return false; | ||
} | ||
|
||
const uniqueDigits = new Set(cardNumber); | ||
if (uniqueDigits.size < 2) { | ||
return false; | ||
} | ||
|
||
if (parseInt(cardNumber[15]) % 2 !== 0) { | ||
return false; | ||
} | ||
|
||
const sumOfDigits = [...cardNumber].reduce((sum, digit) => sum + parseInt(digit), 0); | ||
if (sumOfDigits <= 16) { | ||
return false; | ||
} | ||
|
||
// If all checks pass, return true | ||
return true; | ||
} | ||
|
||
// Test cases | ||
console.log(validateCreditCard("9999777788880000")); // true | ||
console.log(validateCreditCard("6666666666661666")); // true | ||
console.log(validateCreditCard("a92332119c011112")); // false (invalid characters) | ||
console.log(validateCreditCard("4444444444444444")); // false (only one type of number) | ||
console.log(validateCreditCard("1111111111111110")); // false (sum less than 16) | ||
console.log(validateCreditCard("6666666666666661")); // false (odd final number) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not check also cases where number of digits is not exactly 16?