Skip to content

Commit 4b8bce6

Browse files
committed
Implement proper fraction function and tests
1 parent f8c8ca1 commit 4b8bce6

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

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

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

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
return Math.abs(numerator) < Math.abs(denominator);
1515
}
1616

1717
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,3 +31,20 @@ function assertEquals(actualOutput, targetOutput) {
3131

3232
// Example: 1/2 is a proper fraction
3333
assertEquals(isProperFraction(1, 2), true);
34+
35+
assertEquals(isProperFraction(3, 4), true);
36+
assertEquals(isProperFraction(-1, 2), true);
37+
38+
// Equal numerator and denominator
39+
assertEquals(isProperFraction(2, 2), false);
40+
41+
// Improper fractions
42+
assertEquals(isProperFraction(3, 2), false);
43+
assertEquals(isProperFraction(5, 3), false);
44+
assertEquals(isProperFraction(-3, 2), false);
45+
46+
// Zero numerator
47+
assertEquals(isProperFraction(0, 2), true);
48+
49+
// Negative denominator
50+
assertEquals(isProperFraction(1, -2), true);

0 commit comments

Comments
 (0)