Cape Town | 26-ITP-May | Shafiek Walker | Sprint 3 | Practice TDD#1391
Cape Town | 26-ITP-May | Shafiek Walker | Sprint 3 | Practice TDD#1391shafiekwalker7861 wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c34267d to
f961fe6
Compare
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start on this task, there's a few places still to work on though
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return a string that contains the original `str` repeated `count` times. | ||
|
|
||
| function repeatStr(str, count) { |
There was a problem hiding this comment.
Can you put this code into the relevant file please? We try to ensure that test files only have tests in them, and not the actual code.
There was a problem hiding this comment.
Thanks! I've moved the implementation into repeat-str.js and removed the implementation from the test file so it now only contains tests.
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num % 10 === 1 && num % 100 !== 11) { | ||
| return num + "st"; |
There was a problem hiding this comment.
Does this code work, and do you test for, the other ordinals? What about 2nd, 3rd, 4th etc?
There was a problem hiding this comment.
Thanks for the feedback! I've updated the implementation to correctly handle all ordinal suffixes (st, nd, rd, and th), including the special cases (11th, 12th, and 13th). I've also expanded the test suite to cover these additional cases.
This comment has been minimized.
This comment has been minimized.
deleted image comment
LonMcGregor
left a comment
There was a problem hiding this comment.
Good job - the get ordinal task is complete now. I've left another comment for the repeat task.
| } else if (count === 0) { | ||
| return ""; | ||
| } else { | ||
| return str.repeat(count); |
There was a problem hiding this comment.
One of the comments in the original file said
// 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.
Can you try this again without referencing the built-in repeat?

Learners, PR Template
Self checklist
Changelist
Completed the Sprint 3 "Practice TDD" exercises.
Wrote and updated Jest tests, implemented the required functions, and verified that all tests pass using
npm test.