-
-
Notifications
You must be signed in to change notification settings - Fork 396
Manchester | 26-ITP-May | Abdu Hassen | Sprint 3 |practice-tdd #1500
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,11 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
| for (let i = 0; i < stringOfCharacters.length; i++) { | ||
| if (stringOfCharacters[i] === findCharacter) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| module.exports = countChar; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,19 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| let numberValue = num; | ||
| let lastDigit = numberValue % 10; | ||
| let lastTwoDigit = numberValue % 100; | ||
| if (lastTwoDigit === 11 || lastTwoDigit === 12 || lastTwoDigit === 13) { | ||
| return String(numberValue) + "th"; | ||
| } | ||
| if (lastDigit === 1) { | ||
| return String(numberValue) + "st"; | ||
| } | ||
| if (lastDigit === 2) { | ||
| return String(numberValue) + "nd"; | ||
| } | ||
| if (lastDigit === 3) { | ||
| return String(numberValue) + "rd"; | ||
| } else return String(numberValue) + "th"; | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| function repeatStr() { | ||
| function repeatStr(str, num) { | ||
| let result = ""; | ||
| // 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 (num < 0) { | ||
| throw new Error(); | ||
| } | ||
|
|
||
| return str.repeat(num); | ||
|
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. Can you have another look at this task - check the comment at the start which mentions what you should avoid. My original comment was about the if branches you had after your for loop, which was a good implementation. The if branches seemed like they might not be necessary. Can you try re-implementing just the for loop? |
||
| } | ||
|
|
||
| module.exports = repeatStr; | ||
Uh oh!
There was an error while loading. Please reload this page.