-
-
Notifications
You must be signed in to change notification settings - Fork 396
London | 26-ITP-May | Chinwe Chukwuma | Sprint 3 | implement-and-rewrite #1573
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
a74dbb7
6a32e82
d6e6eb8
258f3f7
b125726
bf6a254
979f9ce
149a343
be1bcc7
e7a975e
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 |
|---|---|---|
|
|
@@ -12,8 +12,25 @@ | |
|
|
||
| function isProperFraction(numerator, denominator) { | ||
| // TODO: Implement this function | ||
| if (denominator <= 0) { | ||
| return false; | ||
| } | ||
| if (numerator < 0) { | ||
| return false; | ||
| } | ||
| return numerator < denominator; | ||
| } | ||
|
|
||
| /* A proper fraction is defined as a fraction where: | ||
| - The numerator is less than the denominator. | ||
| - The denominator is positive. | ||
|
|
||
| Source: https://www.mathsisfun.com/proper-fractions.html | ||
|
Comment on lines
+26
to
+28
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. Note: The source does not actually say anything about negative numerator or denominator. No change required because the spec also does not say anything about what to do with negative numbers. |
||
| */ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // The line below allows us to load the isProperFraction function into tests in other files. | ||
| // This will be useful in the "rewrite tests with jest" step. | ||
| module.exports = isProperFraction; | ||
|
|
@@ -31,3 +48,24 @@ function assertEquals(actualOutput, targetOutput) { | |
|
|
||
| // Example: 1/2 is a proper fraction | ||
| assertEquals(isProperFraction(1, 2), true); | ||
| // Proper fractions | ||
| assertEquals(isProperFraction(2, 3), true); | ||
| assertEquals(isProperFraction(3, 4), true); | ||
| assertEquals(isProperFraction(0, 5), true); | ||
|
|
||
| // Improper fractions | ||
| assertEquals(isProperFraction(5, 5), false); | ||
| assertEquals(isProperFraction(7, 3), false); | ||
|
|
||
| // Denominator zero | ||
| assertEquals(isProperFraction(5, 0), false); | ||
|
|
||
| // Negative numerators | ||
| assertEquals(isProperFraction(-1, 2), false); | ||
|
|
||
| // Negative denominators | ||
| assertEquals(isProperFraction(1, -2), false); | ||
|
|
||
| // Both negative | ||
| assertEquals(isProperFraction(-3, -2), false); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { | |
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| test(`should return "Right angle" when angle = 90`, () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| }); | ||
|
|
||
| // Case 3: Obtuse angles | ||
| test(`should return "Obtuse angle" when (90 < angle < 180)`, () => { | ||
| expect(getAngleType(91)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(179)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Straight angle | ||
| test(`should return "Straight angle" when angle = 180`, () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Reflex angles | ||
| test(`should return "Reflex angle" when (180 < angle < 360)`, () => { | ||
| expect(getAngleType(181)).toEqual("Reflex angle"); | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| expect(getAngleType(359)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
||
| // Case 6: Invalid angles | ||
| test(`should return "Invalid angle" for angles outside valid range (1-359)`, () => { | ||
|
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 the value of |
||
| expect(getAngleType(-10)).toEqual("Invalid angle"); | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| expect(getAngleType(360)).toEqual("Invalid angle"); | ||
| expect(getAngleType(400)).toEqual("Invalid angle"); | ||
| }); | ||
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 authoritative source do you base your definition of a proper fraction on?
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.
Thank you @cjyuan for your feedback. I have added authoritative source and made necessary adjustments.