Skip to content

Commit d051c1e

Browse files
authored
Fix isProperFraction logic for negative values
1 parent 06520c4 commit d051c1e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
const properFraction = numerator / denominator;
15-
return properFraction > 0 && properFraction < 1;
14+
return Math.abs(numerator) < Math.abs(denominator)
1615
}
1716

1817
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -41,7 +40,7 @@ assertEquals(isProperFraction(1, 1), false);
4140
assertEquals(isProperFraction(8, 3), false)
4241

4342
// Negative Values
44-
assertEquals(isProperFraction(-3, 8), false);
43+
assertEquals(isProperFraction(-3, 8), true);
4544
assertEquals(isProperFraction(-8, -3), false);
4645
assertEquals(isProperFraction(-3, -8), true);
4746

0 commit comments

Comments
 (0)