Repository navigation
Manchester | 26-ITP-Sept | Aklilu Tsehaye | Sprint 2 | Practice TDD #1703
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
AkliluMihtsun
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
AkliluMihtsun: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
18 commits
Select commit
Hold shift + click to select a range
efb9921
added statement that counts number repeated char in string
AkliluMihtsun 89df6b3
add test case for counting zero occurrences of a character
AkliluMihtsun 9d9553e
implement repeatStr function to concatenate string n times
AkliluMihtsun 6e8bd15
add test case for repeating string one time
AkliluMihtsun 1d03850
refactor repeatStr function to improve error handling and maintain st…
AkliluMihtsun 56d5d43
add tests for handling zero and negative counts in repeatStr function
AkliluMihtsun b63687d
implement function to return ordinal suffixes for numbers ending with…
AkliluMihtsun 2c0fb31
add tests for ordinal suffixes for numbers ending with 1, 2 and 3
AkliluMihtsun 044c4bf
refactor function to improve ordinal suffix handling for 0 [4-9] [11-13]
AkliluMihtsun 5ad739a
add test for ordinal suffix 'th' for numbers ending with 0, 4-9, and …
AkliluMihtsun a7d33f4
refactor repeatStr function to improve error handling and code structure
AkliluMihtsun a1bae13
update test for 'th' suffix to include additional cases for numbers e…
AkliluMihtsun 39191ee
refactor getOrdinalNumber function to simplify 'th' suffix handling
AkliluMihtsun 101e3fc
remove unused regex patterns from getOrdinalNumber function
AkliluMihtsun af8f0bb
refactor getOrdinalNumber function to correctly slice last two digits…
AkliluMihtsun bd684b1
add early return for empty character check in countChar function
AkliluMihtsun 31d6e6c
refactor countChar tests to improve coverage for case sensitivity and…
AkliluMihtsun a999b4c
refactor getOrdinalNumber function to improve variable naming for cla…
AkliluMihtsun 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,6 @@ | ||
| export function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| if (findCharacter === "") { | ||
| return 0; | ||
| } | ||
| return stringOfCharacters.split(findCharacter).length - 1; | ||
| } |
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,14 @@ | ||
| export function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| const numStr = num.toString(); | ||
| const last2ndDigit = numStr.slice(-2, -1); | ||
| const last1stDigit = numStr.slice(-1); | ||
|
|
||
| if (last1stDigit == "1" && last2ndDigit != "1") { | ||
| return `${numStr}st`; | ||
| } else if (last1stDigit == "2" && last2ndDigit != "1") { | ||
| return `${numStr}nd`; | ||
| } else if (last1stDigit == "3" && last2ndDigit != "1") { | ||
| return `${numStr}rd`; | ||
| } | ||
| return `${numStr}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,14 @@ | ||
| export function repeatStr() { | ||
| export function repeatStr(word, n) { | ||
| // 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 (n < 0) { | ||
| throw new Error("Error"); | ||
| } else if (n === 0) { | ||
| return ""; | ||
| } | ||
| let nWords = ""; | ||
| for (let i = 0; i < n; i++) { | ||
| nWords = nWords + word; | ||
| } | ||
| return nWords; | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.