Repository navigation
London | 26-ITP-Sep | Bartosz Kawiak | Sprint 2| Practice-TDD - #1650
bartoszkawiak wants to merge 3 commits into
Conversation
| let count = 0; | ||
| for (let i = 0; i < stringOfCharacters.length; i++) { | ||
| if (stringOfCharacters[i] === findCharacter) { | ||
| count = count + 1; |
There was a problem hiding this comment.
Is there an alternative syntax we can use in JS to increment numbers by one?
| } | ||
| return count; | ||
| } | ||
| //1st test passsed |
There was a problem hiding this comment.
Clean up comments before committing work up
There was a problem hiding this comment.
Is there a smaller first test you could write for this? Have a think of what the simplest starting input could be
| export function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| const exceptions = [11, 12, 13]; | ||
| let strNum = num.toString(); |
There was a problem hiding this comment.
Could strNum be aconst variable? Would this break the code?
| if (strNum.endsWith("1")) { | ||
| return strNum + "st"; | ||
| } else if (strNum.endsWith("2")) { | ||
| return strNum + "nd"; | ||
| } else if (strNum.endsWith("3")) { | ||
| return strNum + "rd"; | ||
| } else { | ||
| return strNum + "th"; | ||
| } |
There was a problem hiding this comment.
Slight refactor possible here: if we are returning a value from each if statement do we need the else if or is a if statement enough?
Here I'm thinking about cleaning up the code to do the bare minimum, avoiding overengineering when it doesn't actually change the behaviour in the code.
| // The goal is to re-implement that function, not to use it. | ||
| return "hellohellohello"; | ||
| export function repeatStr(str, count) { | ||
| return str.repeat(count); |
There was a problem hiding this comment.
This function was specifically NOT meant to call the repeat method but you have done so here. Please re-design this function to not use the repeat method, design logic yourself.
Poonam-raj
left a comment
There was a problem hiding this comment.
I have a few areas I need you to iron out and the repeat-str function needs to be redesigned completely. Please look at my comments and address those changes - thank you
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Completed today’s TDD exercises using Jest. Implemented the required functions and wrote tests to cover the expected behaviour and edge cases.