-
-
Notifications
You must be signed in to change notification settings - Fork 272
Birmingham | 25-ITP-Sep | Hadi-Vahidi | Sprint 3 |sprint-3-implement-and-rewrite #804
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?
Birmingham | 25-ITP-Sep | Hadi-Vahidi | Sprint 3 |sprint-3-implement-and-rewrite #804
Conversation
|
Your PR's title didn't contain a known region. Please check the expected title format, and make sure your region is in the correct place and spelled correctly. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR's title didn't contain a known region. Please check the expected title format, and make sure your region is in the correct place and spelled correctly. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
cjyuan
left a comment
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 changes (file additions) made in the Sprint-1 and Sprint-2 folder are not related to Sprint-3 exercise. Can you revert the changes made in that two folders?
-
Can you check out this PR Guide and update the PR title and PR description accordingly?
| if(numerator===denominator){ | ||
| return false | ||
| } | ||
| if((Math.abs(numerator))<denominator){ | ||
| return true | ||
| } | ||
| if (numerator > denominator) { | ||
| return false; | ||
| } | ||
| if (denominator === 0){ | ||
| return false | ||
| } |
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 statements in the function are evaluated in the order they appear in the code. As soon as the condition on line 11 is evaluated to
true, the function would have returnedtrueimmediately. However, -3/2 is not a proper fraction. -
The spec does not specify whether
denominatorcan be negative or not.
How would you update the function so that it would work equally well whendenominatoris negative? -
If you are up the some challenge, try simplify the code to use at most one if-statement.
| // for (let i=1; i<10; i++){ | ||
| // if (i==5){ | ||
| // return rank === "5" | ||
| // } | ||
| // } |
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.
Why keep this code in a comment?
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 was trying to use for loop and forgot to delete it. sorry
| test ("should return true for negative Fraction",()=>{ | ||
| expect(isProperFraction(-4,7)).toEqual(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.
The test description could be misleading.
-3/2 is not a proper fraction, so isProperFraction(-3,2) should return false.
| test ("should return a 5 for the card with rank of 5 like(5♥) ",()=>{ | ||
| const fiveofHearts = getCardValue("5♥"); | ||
| expect(fiveofHearts).toEqual(5); | ||
|
|
||
| }) |
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.
When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual rank, we will need about 13 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.
For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as
test("should return the value of number cards (2-10)", () => {
expect(getCardValue("2♣︎")).toEqual(2);
expect(getCardValue("5♠")).toEqual(5);
expect(getCardValue("10♥")).toEqual(10);
// Note: We could also use a loop to check all values from 2 to 10.
});
|
|
||
| }) | ||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("shoild return 10 fore the faced cart like king(K♦) and queen (Q♣)") |
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.
- Few words are misspelled
- Could also include
J
|
Your PR's title didn't contain a known region. Please check the expected title format, and make sure your region is in the correct place and spelled correctly. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR's title didn't contain a known region. Please check the expected title format, and make sure your region is in the correct place and spelled correctly. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
cjyuan
left a comment
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.
Changes look good. It seems you had a different definition of pure fraction.
| } | ||
| if (denominator === 0){ | ||
| return false | ||
| if (numerator < denominator && numerator > -denominator) { |
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 math, 2/-3 is equal to -2/3, and -2/-3 = 2/3.
So ideally isProperFraction(2, -3) and isProperFraction(-2, -3) should also true.
Suggestion: Look up the definition of proper fraction.
…ing Math.abs to input numbers
|
Changes look good. |
Learners, PR Template
Self checklist
Changelist
All implemented tests are completed.
Questions