Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 397
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?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4c62400376a6b02323e1087fbee557e3a65bf5c3324ca3f91185c7e7195189a3f957a1b48031e216221ad10fc3c60638b42ac2702f8cf7cff3f69dbf6f3d1d0bdef75630c50255740a46994606e54bbd59aaaa7e7cacfb4a6131aba85a823cc958de919dba42211656b6c5e5b02da209f797b7870f5068896903f4199b94f407bf2File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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,19 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 100 === 11) { | ||
| return num + "th"; | ||
| } else if (num % 100 === 12) { | ||
| return num + "th"; | ||
| } else if (num % 100 === 13) { | ||
| return num + "th"; | ||
| } else if (num % 10 === 1) { | ||
| return num + "st"; | ||
| } else if (num % 10 === 2) { | ||
| return num + "nd"; | ||
| } else if (num % 10 === 3) { | ||
| return num + "rd"; | ||
| } else { | ||
| return num + "th"; | ||
| } | ||
| } | ||
| 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,18 @@ | ||
| 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 (typeof times !== "number" || !Number.isInteger(times)) { | ||
| throw new Error("count must be a whole number"); | ||
| } | ||
| if (times < 0) { | ||
| throw new Error("count cannot be negative"); | ||
| } | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.
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.