-
-
Notifications
You must be signed in to change notification settings - Fork 336
Sheffield| 26-Jan-ITP| Mona-Eltantawy | Sprint 3| Sprint 3 /practice TDD #1282
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
6fac035
1dbf4e3
e21abf0
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,8 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| function countChar(str, char) { | ||
|
|
||
| return str.split(char).length -1; | ||
| } | ||
|
|
||
| module.exports = countChar; | ||
| console.log(countChar('lol', 'l')); | ||
|
|
||
| module.exports = countChar; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| function getOrdinalNumber(n) { | ||
| if (n % 100 >= 11 && n % 100 <= 13) return n + "th"; | ||
|
Contributor
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. Here is an alternative to express the code on line 2: const lastTwoDigits = num % 100;
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) ...
Note: The difference might not be obvious in this example. |
||
|
|
||
| if (n % 10 === 1) return n + "st"; | ||
| if (n % 10 === 2) return n + "nd"; | ||
| if (n % 10 === 3) return n + "rd"; | ||
|
|
||
| return n + "th"; | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
| module.exports = getOrdinalNumber; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| function repeatStr() { | ||
| return "hellohellohello"; | ||
| } | ||
| function repeatStr(str, count) { | ||
| if( count >= 0 ) | ||
| {return str.repeat (count)}; | ||
| else { return 'invalid count'}; | ||
| }; | ||
|
Comment on lines
+1
to
+5
Contributor
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. Indentation is off and some of the code is not consistently formatted. Have you successfully assigned prettier as your default JS code formatter and enabled "Format on save/paste" on VSCode, as recommended in |
||
|
|
||
| module.exports = repeatStr; | ||
| module.exports = repeatStr; | ||
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.
When you are done testing the function, don't forget to remove all debugging code to keep the code clean.