-
-
Notifications
You must be signed in to change notification settings - Fork 337
Glasgow | Jan-26 | Elisabeth Matulian | Sprint 3 | Coursework practice tdd #1005
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 5 commits
a75974d
197be89
712b964
8faba06
75dfc4b
f8f380c
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,10 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
| for (char of stringOfCharacters) { | ||
| if (char === findCharacter) { | ||
| count = count + 1; | ||
| }} | ||
| 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 last2digit = num % 100 | ||
| let lastDigit = num % 10 | ||
| if (last2digit === 11 || last2digit === 12 || last2digit === 13) { | ||
| return `${num}th` | ||
| } | ||
| else if (lastDigit === 1) { | ||
| return `${num}st` | ||
| } | ||
| else if (lastDigit === 2) { | ||
| return `${num}nd` | ||
| } | ||
| else if (lastDigit === 3) { | ||
| return `${num}rd` | ||
| } | ||
| else return `${num}th` | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function repeatStr() { | ||
| return "hellohellohello"; | ||
| function repeatStr(str, count) { | ||
| if (count >= 0) {return str.repeat(count)} | ||
|
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. One little thing, for readability purposes, it's worth putting return and throw on their own lines with braces.
Author
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. Thanks for mentioning, I have changed the position on the line |
||
| else throw new Error("Error") | ||
| } | ||
|
|
||
| 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. Functionality-wise, the tests are correct, but it's going to be hard to distinguish which one fails, given that they are all named the same. How can we improve that?
Author
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. That's true! Didn't think about that. Names's updated:) Could you please take another look when you have a moment? |
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.
Functionality-wise, the test is correct. But it is a tiny bit misplaced in the file, and the name could be a bit more descriptive, based on other tests in this file. Can you try to update it?
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.
the peace of code is moved, name is updated