London | 26-ITP-May | Liridona Shehu | Sprint 3 | Implement and rewrite#1474
London | 26-ITP-May | Liridona Shehu | Sprint 3 | Implement and rewrite#1474shehu-dona wants to merge 23 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
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.
This comment has been minimized.
This comment has been minimized.
| else if( angle > 180 && angle < 360){ | ||
| return "Reflex angle"; | ||
| } | ||
| else return "Invalid angle"; |
There was a problem hiding this comment.
FYI: You don't need the else here as the code will only run if no other condition was true
| if( angle > 0 && angle < 90){ | ||
| return "Acute angle"; | ||
| } | ||
| else if (angle === 90){ | ||
| return "Right angle"; | ||
| } | ||
| else if ( angle > 90 && angle < 180){ | ||
| return "Obtuse angle"; | ||
| } | ||
| else if(angle === 180){ | ||
| return "Straight angle"; | ||
| } | ||
| else if( angle > 180 && angle < 360){ |
There was a problem hiding this comment.
I see some white spaces in the conditions that are not needed. How can you ensure consistent formatting in your code?
| test(`should return "Invalid angle" when (180 < angle < 360)`, () => { | ||
| // Test various invalid angles, including boundary cases | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| expect(getAngleType(360)).toEqual("Invalid angle"); |
There was a problem hiding this comment.
You could add 2 test cases that are not boundary cases
| // Special case: numerator is negative is a proper fraction | ||
| test(`should return false when numerator is negative value`, () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(false); | ||
| }); | ||
|
|
||
|
|
||
| // Special case: denominator is negative is a proper fraction |
There was a problem hiding this comment.
The comments say is a prober fracteion but the function should return false. This is confusing
| }); | ||
|
|
||
|
|
||
| // Special case: negative numerator with smaller value then negative dominator is a proper fraction |
There was a problem hiding this comment.
The comments say is a prober fracteion but the function should return false. This is confusing
| const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; | ||
| const validSuits = ["♠", "♥", "♦", "♣"]; | ||
|
|
||
| let isValidRank = validRanks.includes(rank); | ||
| let isValidSuit = validSuits.includes(suit); | ||
|
|
||
|
|
||
|
|
||
| // Invalid Card | ||
| if( !isValidRank || !isValidSuit ){ | ||
| throw new Error("Invalid Card") |
There was a problem hiding this comment.
Thats a nice way of checking if the input is valid. By expliciting stating all allowed values that code is easy to understand
| // test(`Should throw an error when given an invalid card`, () => { | ||
| // expect(() => getCardValue("1♠")).toThrow(); | ||
| // expect(() => getCardValue("Z♦")).toThrow(); | ||
| // expect(() => getCardValue("11♥")).toThrow(); | ||
| // expect(() => getCardValue("")).toThrow(); | ||
| // }); | ||
|
|
Learners, PR Template
Self checklist
Changelist
A PR with exercises using Jest