Repository navigation
London | 26-ITP-Sep | Bartosz Kawiak | Sprint 2| Practice-TDD #1650
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
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,3 +1,10 @@ | ||
| export function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count = 0; | ||
| for (let i = 0; i < stringOfCharacters.length; i++) { | ||
| if (stringOfCharacters[i] === findCharacter) { | ||
| count = count + 1; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
| //1st test passsed | ||
|
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. Clean up comments before committing work up |
||
|
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. Is there a smaller first test you could write for this? Have a think of what the simplest starting input could be |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,20 @@ | ||
| export function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| const exceptions = [11, 12, 13]; | ||
| let strNum = num.toString(); | ||
|
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. Could |
||
|
|
||
| for (let exception of exceptions) { | ||
| if (strNum.endsWith(exception)) { | ||
| return strNum + "th"; | ||
| } | ||
| } | ||
|
|
||
| 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"; | ||
| } | ||
|
Comment on lines
+11
to
+19
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. Slight refactor possible here: if we are returning a value from each if statement do we need the 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. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| export function repeatStr() { | ||
| // 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. | ||
| return "hellohellohello"; | ||
| export function repeatStr(str, count) { | ||
| return str.repeat(count); | ||
|
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. This function was specifically NOT meant to call the |
||
| } | ||
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.
Is there an alternative syntax we can use in JS to increment numbers by one?