generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 245
West Midlands | ITP-Sept-25 | Mustaf Asani | Sprint 3 | Coursework/sprint 3 implement and rewrite #795
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
asaniDev
wants to merge
30
commits into
CodeYourFuture:main
Choose a base branch
from
asaniDev: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.
Open
West Midlands | ITP-Sept-25 | Mustaf Asani | Sprint 3 | Coursework/sprint 3 implement and rewrite #795
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
26fd354
changed the name of the string in the function
asaniDev 5ab6322
removed line 10 and passed function to console
asaniDev 0c7cc6f
corrected the error with the function
asaniDev cc216e1
added a return to the function
asaniDev 90013dc
moved the return command to the line below it
asaniDev f63f7cf
created a function that returns the bmi
asaniDev a02b0c5
created a function that converts a given string to snake case
asaniDev e097316
created a toPounds function to return a pounds and pence notation
asaniDev 742c228
answered all the questions in the exercise
asaniDev 0d5ad45
wrote tests for any edge cases and fixed resulting bugs
asaniDev 2038048
made a function for angle types and added tests for all angles
asaniDev 7daf16b
added tests for most fraction types and conditions for them as well
asaniDev dfebb97
added conditions for all ranks in a deck of cards and tests for them
asaniDev 6865348
added jest tests for all angle types
asaniDev 43d650c
added jest tests for different card values
asaniDev 3ca95c6
took away comment on line 30
asaniDev c56bd67
revert multiple commits that were from sprint 2
asaniDev 2765c49
added tests for multiple samples, removed a test for ace of spades, c…
asaniDev 035e27e
removed check for ace of spades, adjusted rank to give the full value…
asaniDev 50ee9ef
corrected test for numerator is 0 to a proper fraction, and removed u…
asaniDev bcbd867
added a regex to make sure only exact number card value matches will …
asaniDev 137fd7c
added a few tests for negative improper fractions
asaniDev e5b18e4
added more tests to make the test suites more robust, moved ten to nu…
asaniDev 5fa3d08
removed console.log used for testing.
asaniDev d58910a
used regex pattern to check for ranks and removed includes method
asaniDev 8b52886
added dev dependencies
asaniDev 78f21df
revert changes to sprint 2 folder
asaniDev 8ad9d08
reverted changes to 1.js
asaniDev 14ddfad
reverted changes to 2.js in sprint 2 file.
asaniDev 1a5aada
revert unwanted change
asaniDev 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
Some comments aren't visible on the classic Files Changed page.
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,11 +8,33 @@ | |
| // 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) { | ||
| if (rank === "A") { | ||
| function strictNumber(rank) { | ||
| if (/^(0|[1-9][0-9]*)$/.test(rank)) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| const pattern = /^(?:[2-9]|10)$/; | ||
| let rank = card.slice(0, card.length - 1); | ||
|
|
||
| if (strictNumber(rank)) { | ||
| if (pattern.test(Number(rank))) { | ||
| return Number(rank); | ||
| } | ||
| } | ||
|
|
||
| const faceCardPattern = /^[JQK]$/; | ||
|
|
||
| if (faceCardPattern.test(rank)) { | ||
| return 10; | ||
| } else if (/^A$/.test(rank)) { | ||
|
Contributor
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. Could also just write |
||
| return 11; | ||
| } else { | ||
| return "Invalid card rank."; | ||
| } | ||
| } | ||
|
|
||
| console.log(`Jack will give ${getCardValue("J♥")}`); | ||
| // The line below allows us to load the getCardValue function into tests in other files. | ||
| // This will be useful in the "rewrite tests with jest" step. | ||
| module.exports = getCardValue; | ||
|
|
@@ -38,20 +60,25 @@ assertEquals(aceofSpades, 11); | |
| // 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♥"); | ||
| const fiveofHearts = getCardValue("9♥"); | ||
| // ====> write your test here, and then add a line to pass the test in the function above | ||
|
|
||
| assertEquals(fiveofHearts, 9); | ||
| // 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); | ||
| // 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 ace = getCardValue("A♥"); | ||
| assertEquals(ace, 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("100♠"); | ||
| assertEquals(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
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.
Is the outer
ifstatement necessary?