-
-
Notifications
You must be signed in to change notification settings - Fork 197
WM | 25-ITP-May | Nahom Mesfin | Sprint 3 coursework #677
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?
WM | 25-ITP-May | Nahom Mesfin | Sprint 3 coursework #677
Conversation
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.
Good start, but you may want to take more time to work on this sprint - there are a few tasks that have problems.
@@ -9,6 +9,7 @@ | |||
|
|||
function isProperFraction(numerator, denominator) { | |||
if (numerator < denominator) return true; |
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.
What happens if I call isProperFraction(-70,5)?
-70/5 is not a proper fraction.
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 assertion will fail because i have not used aboslute value Maths.abs
in my function to determine if a negative fractioon is really a proper fraction or not. I have fixed and changed the condition to return absolute values.
line 11
- I have change the if conditon to
return Math.abs(numerator) < Math.abs(denominator);
if (rank === "A") return 11; | ||
if (rank >= '2' && rank <= '9') return Number(rank); |
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.
What happens if I call getCardValue("222♥")?
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.
Yes, it should have thrown an error, but because of string comparison of "222" and "2" it will pass the condition and logs 222. I have fixed this issue by using regular expression.
- Updated line 13
if (/^[2-9]$/.test(rank)) return Number(rank);
@@ -1,5 +1,11 @@ | |||
function countChar(stringOfCharacters, findCharacter) { | |||
return 5 | |||
let count = 0; |
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.
This is very minor - try to keep the indentation the same for all the code. here your first declaration is indented further.
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.
Ok, I will. thanks for noticing, I have adjusted the identation.
@@ -1,5 +1,8 @@ | |||
function getOrdinalNumber(num) { |
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.
In english we would say "21st" - can you make your code work in these general cases too?
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.
I have updated the function to include cases like 21st, 22nd and so on. I have used a modulo operator to get the last digits of the numbers num % 10;
and num % 100;
and used them to determine the cases for each number.
- Updated line 2 to 10
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(str, count) { | ||
return str.repeat(count); |
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.
What about your error condition you are testing for?
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.
Yes, i should have added an error conditon to throw an error. I have added an error that throws a negative integer.
- line 2 - 4
if (count < 0) { throw new Error("Count must be a non-negative integer."); }
Great work making these changes - you are done with this sprint now |
Learners, PR Template
Self checklist
Changelist
In Implement, I wrote functions step-by-step with assertions to cover different cases. In Rewrite, I converted previous assertions to use Jest syntax for clearer and easier testing. In Practice I built and ran tests using Jest and vscode's code runner to ensure all functions meet requirements.