generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 241
Manchester| 25-ITP-September | Fithi Teklom| Sprint 3 | 2-practice-tdd #863
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
Fithi-Teklom
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
Fithi-Teklom:2-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
31f50ad
count.js updated
Fithi-Teklom a61f9b1
updated pr template
Fithi-Teklom 2a422f5
updated PR template
Fithi-Teklom 04f5a7f
get ordinal numbers updated template
Fithi-Teklom 7e9160d
ordinal numbers updated PR template
Fithi-Teklom 6c17f89
repeat.js updated template
Fithi-Teklom 94de70c
repeat.test.js updated template
Fithi-Teklom 44ce568
adjusted Pr template
Fithi-Teklom 8eaf08c
Added comment
Fithi-Teklom e145d3c
Resolved merge conflict: kept repeat.js
Fithi-Teklom e7cad87
count.test.js passed all the tests
Fithi-Teklom 17a2043
deleted repeat.js and adjusted repeat.str.test.js
Fithi-Teklom 4f483dd
modified PR
Fithi-Teklom 9e31389
nothing changed
Fithi-Teklom f409459
restored 3-stretch from origin/main
Fithi-Teklom 78dd2fd
restored Sprint2 5-stretch-extend
Fithi-Teklom 84090e8
moved the test to the test.js file
Fithi-Teklom e0d530d
made sure the tests all passed.
Fithi-Teklom 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
| for (let char of stringOfCharacters) { | ||
| if (char === findCharacter) count++; | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| module.exports = countChar; | ||
| module.exports = countChar; |
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,24 @@ | ||
|
|
||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| const remainder10 = num % 10; | ||
| const remainder100 = num % 100; | ||
|
|
||
| if (remainder100 >= 11 && remainder100 <= 13) { | ||
| return `${num}th`; | ||
| } | ||
|
|
||
| switch (remainder10) { | ||
| case 1: | ||
| return `${num}st`; | ||
| case 2: | ||
| return `${num}nd`; | ||
| case 3: | ||
| return `${num}rd`; | ||
| default: | ||
| return `${num}th`; | ||
| } | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
|
|
||
|
|
|
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. Have you tried running this test script to make sure it can run properly?
Author
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. Now I have made sure that the tests have all passed. |
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,9 @@ | ||
| function repeatStr() { | ||
| return "hellohellohello"; | ||
| function repeatStr(str, count) { | ||
|
|
||
| if (count < 0) { | ||
| throw new Error("Count must be a non-negative integer"); | ||
| } | ||
| return str.repeat(count); | ||
| } | ||
|
|
||
| module.exports = repeatStr; |
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,32 +1,20 @@ | ||
| // Implement a function repeatStr | ||
| const repeatStr = require("./repeat-str"); | ||
| // Given a target string str and a positive integer count, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should: | ||
|
|
||
| // case: repeat String: | ||
| // Given a target string str and a positive integer count, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should repeat the str count times and return a new string containing the repeated str values. | ||
|
|
||
| const repeatStr = require("./repeat-str"); | ||
|
|
||
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 3; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hellohellohello"); | ||
| expect(repeatStr("hello", 3)).toBe("hellohellohello"); | ||
| }); | ||
|
|
||
| // case: handle Count of 1: | ||
| // Given a target string str and a count equal to 1, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition. | ||
| test("should return the original string when count is 1", () => { | ||
| expect(repeatStr("world", 1)).toBe("world"); | ||
| }); | ||
|
|
||
| // case: Handle Count of 0: | ||
| // Given a target string str and a count equal to 0, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return an empty string, ensuring that a count of 0 results in an empty output. | ||
| test("should return an empty string when count is 0", () => { | ||
| expect(repeatStr("test", 0)).toBe(""); | ||
| }); | ||
|
|
||
| test("should throw an error when count is negative", () => { | ||
| expect(() => repeatStr("oops", -2)).toThrow("Count must be a non-negative integer"); | ||
| }); | ||
|
|
||
| // case: Negative Count: | ||
| // Given a target string str and a negative integer count, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should throw an error or return an appropriate error message, as negative counts are not valid. |
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.