generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 239
Glasgow | 25-ITP-Sep | Fares Bakhet | Sprint 3 | coursework/sprint-3-practice-tdd #757
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
Fares-Bakhet
wants to merge
12
commits into
CodeYourFuture:main
Choose a base branch
from
Fares-Bakhet: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.
+108
−12
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6ab27fc
Biuld a countChar Code
Fares-Bakhet 9c2b470
Pass the count code test
Fares-Bakhet 48dba8f
Build getOrdinalNumber code
Fares-Bakhet 76de1ca
Pass getOrdinalNumber tests
Fares-Bakhet 7323aba
Build a function repeat code
Fares-Bakhet 80cde9a
Pass the function repeat tests
Fares-Bakhet bea3492
Deleting the unreachable code and else form the last return
Fares-Bakhet 44f3ca1
Grouping the tests
Fares-Bakhet c2a674b
Editing the code
Fares-Bakhet 7d3028f
Editing last test
Fares-Bakhet 1590eec
Delete unsued code
Fares-Bakhet 2478386
Removing all the unnecessary
Fares-Bakhet 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,12 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| function countChar(str, char) { | ||
| return str.split(char).length - 1; | ||
| } | ||
|
|
||
| module.exports = countChar; | ||
|
|
||
| console.log( | ||
| countChar( | ||
| "The split() method of String values takes a pattern and divides this string into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.", | ||
| "a" | ||
| ) | ||
| ); |
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,43 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| num = num.toString(); | ||
| if ( | ||
| num.slice(-2) === "11" || | ||
| num.slice(-2) === "12" || | ||
| num.slice(-2) === "13" | ||
| ) { | ||
| return num + "th"; | ||
| } | ||
| if (num.slice(-1) === "1") { | ||
| return num + "st"; | ||
| } | ||
| if (num.slice(-1) === "2") { | ||
| return num + "nd"; | ||
| } | ||
| if (num.slice(-1) === "3") { | ||
| return num + "rd"; | ||
| } | ||
| return num + "th"; | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
|
|
||
| console.log(getOrdinalNumber(1)); | ||
| console.log(getOrdinalNumber(2)); | ||
| console.log(getOrdinalNumber(3)); | ||
| console.log(getOrdinalNumber(4)); | ||
| console.log(getOrdinalNumber(5)); | ||
| console.log(getOrdinalNumber(6)); | ||
| console.log(getOrdinalNumber(7)); | ||
| console.log(getOrdinalNumber(8)); | ||
| console.log(getOrdinalNumber(9)); | ||
| console.log(getOrdinalNumber(10)); | ||
| console.log(getOrdinalNumber(11)); | ||
| console.log(getOrdinalNumber(12)); | ||
| console.log(getOrdinalNumber(13)); | ||
| console.log(getOrdinalNumber(21)); | ||
| console.log(getOrdinalNumber(22)); | ||
| console.log(getOrdinalNumber(23)); | ||
| console.log(getOrdinalNumber(101)); | ||
| console.log(getOrdinalNumber(111)); | ||
| console.log(getOrdinalNumber(112)); | ||
| console.log(getOrdinalNumber(113)); |
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 @@ | ||
| function repeat() { | ||
| return "hellohellohello"; | ||
| function repeat(str, count) { | ||
| if (count < 0) { | ||
| throw new Error("Count must be a non-negative integer"); | ||
| } | ||
| let result = ""; | ||
| for (let i = 0; i < count; i++) { | ||
| result += str; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| module.exports = repeat; | ||
|
|
||
| console.log(repeat("hello", 3)); |
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.
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.
To ensure thorough testing, we need broad scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories. Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.
For example, we can prepare a test for numbers 2, 22, 132, etc. as
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.
@cjyuan, Done 🫡