Repository navigation
London | 26-ITP-Sep | Shirin Panahian | Sprint 2 | Practice TDD #1721
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
shirinpanahian
wants to merge
6
commits into
CodeYourFuture:main
Choose a base branch
from
shirinpanahian:coursework/sprint-3-practice-tdd
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c335f3
code work for test
shirinpanahian 5ed8914
check every edge case
shirinpanahian 3efdae4
both condition is working
shirinpanahian 472c728
Implement st, nd, rd, and th suffixes
shirinpanahian f5154ef
complete repeat function and jest test
shirinpanahian df91c9f
cover ordinal suffix exceptions and edge cases
shirinpanahian 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| export function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
| let position = stringOfCharacters.indexOf(findCharacter); | ||
| if (position === -1) { | ||
| return 0; | ||
| } else { | ||
| while (position !== -1) { | ||
| count++; | ||
| position = stringOfCharacters.indexOf(findCharacter, position + 1); | ||
| } | ||
| return count; | ||
| } | ||
| } |
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,3 +1,15 @@ | ||
| export function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 10 === 1 && num % 100 != 11) { | ||
| return `${num}st`; | ||
| } | ||
|
|
||
| if (num % 10 === 2 && num % 100 != 12) { | ||
| return `${num}nd`; | ||
| } | ||
|
|
||
| if (num % 10 === 3 && num % 100 != 13) { | ||
| return `${num}rd`; | ||
| } | ||
|
|
||
| return `${num}th`; | ||
| } |
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,5 +1,12 @@ | ||
| export function repeatStr() { | ||
| export function repeatStr(str, count) { | ||
| // Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat). | ||
| // The goal is to re-implement that function, not to use it. | ||
| return "hellohellohello"; | ||
| if (count < 0) { | ||
| throw new Error("negative counts are not valid"); | ||
| } | ||
| let strRep = ""; | ||
| for (let i = 0; i < count; i++) { | ||
| strRep += str; | ||
| } | ||
| return strRep; | ||
| } |
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.
This program seems not quite right to me. Why input cannot be ended with 11 or 22 or 33 ? They should all be valid. Please check the definition of ordinal number carefully, and fix the program (with test cases). Thank you.
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.
Thanks for the feedback! I've corrected the ordinal number tests to handle the special cases ending in 11, 12, and 13, and added test cases for numbers ending in 22 and 33 to ensure they return
ndandrdrespectively.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.
Well done, and it looks better now.