Repository navigation
London | 26-ITP-Sep | Sakiya Mayow | Sprint 2 | Practice TDD #1736
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
e2cbd98
09fa3df
22b0009
eac53d4
8f585b0
c80fcfc
1b77163
01358ab
ecbd8d9
44661d3
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,3 +1,10 @@ | ||
| export function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
|
|
||
| for (let i = 0; i < stringOfCharacters.length; i++) { | ||
| if (stringOfCharacters[0] === findCharacter) { | ||
| count = count + 1; | ||
| } | ||
| } | ||
| return count; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,25 @@ | ||
| export function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 100 === 11) { | ||
| return `${num}th`; | ||
| } | ||
| if (num % 100 === 12) { | ||
| return `${num}th`; | ||
| } | ||
|
|
||
| if (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`; | ||
| } |
|
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. Good test cases coverage. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| export 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"; | ||
| export function repeatStr(str, count) { | ||
| if (count < 0) { | ||
| throw new Error("Count cannot be negative"); | ||
| } | ||
| let result = ""; | ||
|
|
||
| for (let i = 0; i < count; i++) { | ||
| result = result + str; | ||
| } | ||
| return result; | ||
| } |
|
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. Your test cases are correct. Just for you to think a little bit more, besides |
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.
This test case is correct. However, there is a special
strwhich would give 0 anyway. Can you think of it? If so, please add it as well. Thank you.