generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 239
London | 25-ITP-September | Alexandru Pocovnicu | Coursework/sprint 3 implement and rewrite #766
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
Open
alexandru-pocovnicu
wants to merge
9
commits into
CodeYourFuture:main
Choose a base branch
from
alexandru-pocovnicu:coursework/sprint-3-implement-and-rewrite
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.
+4,594
−25
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9dd422c
completed function to get angle types and wrote the assertions for it
alexandru-pocovnicu d90591a
wrote assertions for extra cases and updated the function accordingly
alexandru-pocovnicu a447339
added assertions for cardvalue-updated getCardValue function accordin…
alexandru-pocovnicu 4c94663
updated jest
alexandru-pocovnicu b806538
wrote test cases for acute, obtuse, straight, and reflex angles
alexandru-pocovnicu 3143f7e
created tests for identifying improper fractions and negative proper …
alexandru-pocovnicu 463d531
added tests for handling number cards and face cards in getCardValue …
alexandru-pocovnicu 801f259
refactor password validation logic and enhance test coverage for vari…
alexandru-pocovnicu fcd1c54
refactor angle type checks for improved readability and consistency
alexandru-pocovnicu 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
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,9 +8,18 @@ | |
| // write one test at a time, and make it pass, build your solution up methodically | ||
| // just make one change at a time -- don't rush -- programmers are deep and careful thinkers | ||
| function getCardValue(card) { | ||
| const rank=card.slice(0,-1); | ||
| const numberRank=Number(rank) | ||
| if(numberRank>=2 && numberRank<10){ | ||
| return numberRank; | ||
| } | ||
| if(rank==="10" || rank==="J" || rank==="Q" || rank==="K"){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting: it is usually preferred to give equality checks with a space, so rank === "10" instead of rank==="10". |
||
| return 10 | ||
| } | ||
| if (rank === "A") { | ||
| return 11; | ||
| } | ||
| return "Invalid card rank."; | ||
| } | ||
|
|
||
| // The line below allows us to load the getCardValue function into tests in other files. | ||
|
|
@@ -26,32 +35,53 @@ function assertEquals(actualOutput, targetOutput) { | |
| `Expected ${actualOutput} to equal ${targetOutput}` | ||
| ); | ||
| } | ||
|
|
||
| function invalidCardRank(actualOutput, targetOutput) { | ||
| console.assert( | ||
| actualOutput === targetOutput, | ||
| "Invalid card rank" | ||
| ); | ||
| } | ||
| // Acceptance criteria: | ||
|
|
||
| // Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A), | ||
| // Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will | ||
| // be a number 2-10, or one letter of J, Q, K, A), | ||
| // When the function getCardValue is called with this card string as input, | ||
| // Then it should return the numerical card value | ||
| const aceofSpades = getCardValue("A♠"); | ||
| assertEquals(aceofSpades, 11); | ||
| // const aceofSpades = getCardValue("A♠"); | ||
| // assertEquals(aceofSpades, 11); | ||
|
|
||
| // Handle Number Cards (2-10): | ||
| // Given a card with a rank between "2" and "9", | ||
| // When the function is called with such a card, | ||
| // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). | ||
| const fiveofHearts = getCardValue("5♥"); | ||
| assertEquals(fiveofHearts,5) | ||
|
|
||
| const sixofHearts = getCardValue("6♥"); | ||
| assertEquals(sixofHearts, 6); | ||
| // ====> write your test here, and then add a line to pass the test in the function above | ||
|
|
||
| // Handle Face Cards (J, Q, K): | ||
| // Given a card with a rank of "10," "J," "Q," or "K", | ||
| // When the function is called with such a card, | ||
| // Then it should return the value 10, as these cards are worth 10 points each in blackjack. | ||
| const faceCards = getCardValue("J♥"); | ||
| assertEquals(faceCards,10) | ||
|
|
||
| assertEquals(getCardValue("Q♥"),10); | ||
|
|
||
|
|
||
| // Handle Ace (A): | ||
| // Given a card with a rank of "A", | ||
| // When the function is called with an Ace, | ||
| // Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack. | ||
| const aceofSpades = getCardValue("A♠"); | ||
| assertEquals(aceofSpades, 11); | ||
|
|
||
| // Handle Invalid Cards: | ||
| // Given a card with an invalid rank (neither a number nor a recognized face card), | ||
| // When the function is called with such a card, | ||
| // Then it should throw an error indicating "Invalid card rank." | ||
| const invalidCard = getCardValue("m"); | ||
| invalidCardRank(invalidCard, "Invalid card rank."); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,30 @@ | ||
| function passwordValidator(password) { | ||
| return password.length < 5 ? false : true | ||
| //console.log(password !== password.toUpperCase()); | ||
| let password2=password.split("") | ||
| console.log(password2); | ||
| let newPassword=[]; | ||
| // if ( | ||
| // password.length >= 5 && | ||
| // password !== password.toLowerCase() && | ||
| // password !== password.toUpperCase() | ||
|
|
||
| // ) { | ||
| // return true; | ||
| // } | ||
| for(element of password2){ | ||
| if ( | ||
| password2.length >= 5 && | ||
| /[A-Za-z]/.test(password2) | ||
|
|
||
| ) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
|
|
||
| module.exports = passwordValidator; | ||
| console.log(passwordValidator("434398866")); | ||
|
|
||
| module.exports = passwordValidator; |
This file contains hidden or 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
Oops, something went wrong.
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.
Spacing again before the ||