London | 26-ITP-May | Vito Moratti | Sprint 3 | practice tdd#1526
London | 26-ITP-May | Vito Moratti | Sprint 3 | practice tdd#1526vmoratti wants to merge 9 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start, I have a few follow up comments
| let count = 0; | ||
| for (let char of stringOfCharacters) { | ||
| if (char === findCharacter) { | ||
| count ++; |
There was a problem hiding this comment.
Purely a matter a style, I recommend putting the increment operator immediately after the variable, without a space.
| @@ -1,5 +1,32 @@ | |||
| function getOrdinalNumber(num) { | |||
| return "1st"; | |||
| if (num % 100 === 11) { | |||
There was a problem hiding this comment.
As these first 3 branches are all returning the same thing, is there a way they could be simplified?
There was a problem hiding this comment.
I have now changed it and combined those branches in one.
|
|
||
| module.exports = repeatStr; | ||
| //console.log(repeatStr("hello", -1)); | ||
| //console.log(repeatStr("hello", 0)); |
There was a problem hiding this comment.
Remember to remove commented out code if it is not needed
| var i; | ||
| if (num < 0) { | ||
| throw new Error("negative numbers are not valid"); | ||
| } else if (num === 0) { |
There was a problem hiding this comment.
What does this special num===0 case do?
There was a problem hiding this comment.
Thanks. I have now removed it and code is works still.
Updated the getOrdinalNumber function to correctly handle numbers ending in 11, 12, and 13 as 'th'. Added additional test cases for validation.
Removed unnecessary checks for zero and commented-out test cases.
|
Great! This task is complete now |
Learners, PR Template
Self checklist
Changelist
I had to rewrite all the code and tests.