Skip to content

Commit 07732b4

Browse files
committed
fix bug in results when one of numbers is negative
1 parent bd14a66 commit 07732b4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
15-
if (denominator === 0 || numerator / denominator > 1) {
15+
if (denominator === 0 || Math.abs(numerator / denominator) > 1) {
1616
return false;
1717
}
1818
return true;
@@ -50,6 +50,12 @@ const testCases = [
5050
[6, 3, false],
5151
[8, 4, false],
5252
[10, 5, false],
53+
[-1, 2, true],
54+
[2, -4, true],
55+
[-3, -6, true],
56+
[-4, 0, false],
57+
[0, 5, true],
58+
[-5, 4, false],
5359
];
5460

5561
// loop through each case and assert that the output is correct

0 commit comments

Comments
 (0)