-
-
Notifications
You must be signed in to change notification settings - Fork 196
Sheffield | May-2025 | Declan Williams | Sprint-3 #623
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 2 commits
be25f2c
4fa86db
d317d4f
dea34f8
952fd14
8cf3f58
6da0615
45209eb
37f345d
ed4eaf3
a0d4fcf
d32c392
e7f3d74
2e2d63c
900385e
67c92c2
60ed74f
bcdba1c
a16c211
aced4d1
0a913b0
de7632b
aa7b3ee
d2a8646
9798ed9
63a66e2
c89c3b8
2b44bf7
df5287d
1f02ed6
900db99
5d2265b
525641a
4f81c7d
d34ba19
dd38ca5
5798163
a8d9ac3
1a34fcf
c5d4342
e4b3cf0
885b7d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. In mathematics, -4/7 == 4/-7, and -4/-7 == 4/7. Similarly, -5/2 == 5/-2, and -5/-2 == 5/2. Hint: we can compare the absolute value of both parameters instead. 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. fixed the logic to handle division by zero and simplify return statement to correct the issues |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
else return false; // returns false if numerator is not less than denominator | ||
if (denominator === 0) return false; // avoid division by zero | ||
return Math.abs(numerator) < Math.abs(denominator); | ||
Comment on lines
+2
to
+3
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. The condition at line 3 could also take case of cases where denominator is 0. |
||
} | ||
|
||
module.exports = isProperFraction; |
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.
This is good.
Since
NaN
is also of type "number", you could also consider rejectingNaN
.