-
-
Notifications
You must be signed in to change notification settings - Fork 398
London | 26-ITP-May | Jorvan White | Sprint 3 | Practice TDD #1602
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
4c62400
376a6b0
2323e10
87fbee5
57e3a65
bf5c332
4ca3f91
185c7e7
195189a
3f957a1
b48031e
216221a
d10fc3c
60638b4
2ac2702
f8cf7cf
f3f69db
f6f3d1d
0bdef75
630c502
55740a4
6994606
e54bbd5
9aaaa7e
7cacfb4
a6131ab
a85a823
cc958de
919dba4
2211656
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,11 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0 | ||
| for (const char of stringOfCharacters) { | ||
| if (char === findCharacter) { | ||
| count++ | ||
| } | ||
| } | ||
| return count | ||
| } | ||
|
|
||
| module.exports = countChar; |
|
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. There should be one more boundary case making |
|
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. I think the question requires to also handle 2nd and 3rd etc. Since the question itself may not be quite clear about that, you may clarify in slack channel. Thanks. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 100 === 11) { | ||
| return num + "th"; | ||
| } else if (num % 10 === 1) { | ||
| return num + "st"; | ||
| } else { | ||
| return num | ||
| } | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; |
|
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. if the question requires to also handle 2nd and 3rd etc, then there will be more test cases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| function repeatStr() { | ||
| // 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"; | ||
| } | ||
| function repeatStr(str, times) { | ||
| if (times === 0) { | ||
| return ""; | ||
|
Comment on lines
+2
to
+3
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. why this |
||
| } else if (times < 0) { | ||
| throw new Error("error"); | ||
| } | ||
|
|
||
| let repeatedString = ""; | ||
| for (let i = 0; i < times; i++) { | ||
| repeatedString += str; | ||
| } | ||
| return repeatedString; | ||
| } | ||
|
|
||
| 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. How about empty string (with the same set of |
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.
semicolon missing in line 5 and line 8.