Skip to content

Commit 675f16e

Browse files
committed
fixed proper-fraction function. (Math.abs())
1 parent d24a40f commit 675f16e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

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

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
15-
// if (numerator < denominator) {
16-
// return true
17-
// }
18-
return numerator < denominator;
14+
// should change negative numbers to absolute numbers
15+
return Math.abs(numerator) < Math.abs(denominator);
1916
}
2017

2118
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -40,7 +37,13 @@ assertEquals(isProperFraction(1, 2), true);
4037
// Tests
4138
assertEquals(isProperFraction(2, 3), true);
4239
assertEquals(isProperFraction(3, 1), false);
43-
assertEquals(isProperFraction(-1, -6), false);
44-
assertEquals(isProperFraction(-1, 0), true);
40+
assertEquals(isProperFraction(-1, -6), true);
41+
assertEquals(isProperFraction(-1, 0), false);
4542
assertEquals(isProperFraction(1, 1), false);
46-
assertEquals(isProperFraction(-6, 6), true);
43+
assertEquals(isProperFraction(-6, 6), false);
44+
45+
assertEquals(isProperFraction(-1, -2), true);
46+
assertEquals(isProperFraction(1, -2), true);
47+
assertEquals(isProperFraction(-1, 2), true);
48+
assertEquals(isProperFraction(1, 0), false);
49+
assertEquals(isProperFraction(-1, 0), false);

0 commit comments

Comments
 (0)