-
-
Couldn't load subscription status.
- Fork 240
London | 25-ITP-SEP | Imran Mohamed| Sprint 3 | Coursework/sprint 3 implement and rewrite #791
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
1ee1bc0
17de75c
0db0719
58b4b7e
0e18f06
2755b3f
014892f
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 |
|---|---|---|
|
|
@@ -8,9 +8,18 @@ | |
| // write one test at a time, and make it pass, build your solution up methodically | ||
|
|
||
| function isProperFraction(numerator, denominator) { | ||
| if (numerator < denominator) { | ||
| if (Math.abs(numerator) < Math.abs(denominator)) { | ||
| return true; | ||
| } | ||
| if (numerator >= denominator) { | ||
| return false; | ||
| } | ||
| if(numerator == 0 && denominator != 0){ | ||
| return true; | ||
| } | ||
|
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. I think you should review the acceptance criteria again for this one and look at the explanation 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 is a stretch scenario I created, I have updated the code to ensure the condition also checks that the denominator is non-zero. |
||
| if (denominator === 0) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // The line below allows us to load the isProperFraction function into tests in other files. | ||
|
|
@@ -47,13 +56,48 @@ assertEquals(improperFraction, false); | |
| // Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true. | ||
| const negativeFraction = isProperFraction(-4, 7); | ||
| // ====> complete with your assertion | ||
|
|
||
| assertEquals(negativeFraction, true); | ||
| // Equal Numerator and Denominator check: | ||
| // Input: numerator = 3, denominator = 3 | ||
| // target output: false | ||
| // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. | ||
| const equalFraction = isProperFraction(3, 3); | ||
| // ====> complete with your assertion | ||
|
|
||
| assertEquals(equalFraction, false); | ||
| // Stretch: | ||
| // What other scenarios could you test for? | ||
| // Zero Numerator check: | ||
| // Input: numerator = 0, denominator = 5 | ||
| // target output: true | ||
| // Explanation: The fraction 0/5 is a proper fraction because the numerator (0) is less than the denominator (5). The function should return true. | ||
| const zeroNumerator = isProperFraction(0, 5); | ||
| // ====> complete with your assertion | ||
| assertEquals(zeroNumerator, true); | ||
| // Zero Denominator check: | ||
| // Input: numerator = 4, denominator = 0 | ||
| // target output: false | ||
| // Explanation: The fraction 4/0 is undefined because division by zero is not allowed. The function should return false. | ||
| const zeroDenominator = isProperFraction(4, 0); | ||
| // ====> complete with your assertion | ||
| assertEquals(zeroDenominator, false); | ||
| // Negative Denominator check: | ||
| // Input: numerator = 3, denominator = -5 | ||
| // target output: true | ||
| // Explanation: The fraction 3/-5 is a proper fraction because the absolute value of the numerator (3) is less than the absolute value of the denominator (5). The function should return true. | ||
| const negativeDenominator = isProperFraction(3, -5); | ||
| // ====> complete with your assertion | ||
| assertEquals(negativeDenominator, true); | ||
| // Both Negative check: | ||
| // Input: numerator = -2, denominator = -6 | ||
| // target output: true | ||
| // Explanation: The fraction -2/-6 is a proper fraction because the absolute value of the numerator (2) is less than the absolute value of the denominator (6). The function should return true. | ||
| const bothNegative = isProperFraction(-2, -6); | ||
| // ====> complete with your assertion | ||
| assertEquals(bothNegative, true); | ||
| // Zero Numerator and Denominator check: | ||
| // Input: numerator = 0, denominator = 0 | ||
| // target output: false | ||
| // Explanation: The fraction 0/0 is undefined. The function should return false. | ||
| const zeroNumeratorDenominator = isProperFraction(0, 0); | ||
| // ====> complete with your assertion | ||
| assertEquals(zeroNumeratorDenominator, false); | ||
Uh oh!
There was an error while loading. Please reload this page.
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 think your implementation of the getAngleType function is logically correct, and follow TDD principles good work