-
-
Notifications
You must be signed in to change notification settings - Fork 390
West Midlands | ITP-26-May | Alina Sofragiu | Sprint 3 | Practice TDD #1420
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| return stringOfCharacters.split("").filter((char) => char === findCharacter) | ||
| .length; | ||
| } | ||
|
|
||
| module.exports = countChar; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 100 >= 11 && num % 100 <= 13) { | ||
| return num + "th"; | ||
| } | ||
|
|
||
| if (num % 10 === 1) { | ||
| return num + "st"; | ||
| } | ||
|
|
||
| if (num % 10 === 2) { | ||
| return num + "nd"; | ||
| } | ||
|
|
||
| if (num % 10 === 3) { | ||
| return num + "rd"; | ||
| } | ||
|
|
||
| return num + "th"; | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,17 @@ | ||
| function repeatStr() { | ||
| 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("Invalid count"); | ||
| } | ||
|
|
||
| let result = ""; | ||
|
|
||
| for (let i = 0; i < count; i++) { | ||
| result += str; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| module.exports = repeatStr; |
|
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. These are good to test your edge cases. Do any of these test the normal operation of the repeat function?
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. yes, first test checks that the string is repeated multiple times count=3 and the second one checks the normal case count=1 |
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.
Good test case for 0. Are there any other test cases you think you should add?
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.
yes, I added more test cases for a single occurrence, an empty string, and case sensitivity