-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
16d8425
0e39798
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.
Author
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. Noted. Thank you @cjyuan. |
||
| */ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // 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); | ||
|
|
||
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.