Skip to content

Commit 32d92f5

Browse files
Implement isProperFraction function and add comprehensive tests
1 parent 6e25287 commit 32d92f5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 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 numerator > 0 && denominator > 0 && numerator < denominator;
1515
}
1616

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

3232
// Example: 1/2 is a proper fraction
3333
assertEquals(isProperFraction(1, 2), true);
34+
35+
// Proper fractions - should return true
36+
assertEquals(isProperFraction(3, 4), true);
37+
assertEquals(isProperFraction(1, 5), true);
38+
assertEquals(isProperFraction(2, 3), true);
39+
assertEquals(isProperFraction(5, 8), true);
40+
assertEquals(isProperFraction(1, 100), true);
41+
42+
// Improper fractions - should return false
43+
assertEquals(isProperFraction(2, 1), false);
44+
assertEquals(isProperFraction(5, 3), false);
45+
assertEquals(isProperFraction(4, 4), false);
46+
assertEquals(isProperFraction(10, 5), false);
47+
assertEquals(isProperFraction(100, 99), false);
48+
49+
// Edge cases with zero - should return false
50+
assertEquals(isProperFraction(0, 5), false);
51+
assertEquals(isProperFraction(0, 1), false);
52+
53+
// Negative numbers - should return false
54+
assertEquals(isProperFraction(-1, 2), false);
55+
assertEquals(isProperFraction(1, -2), false);
56+
assertEquals(isProperFraction(-1, -2), false);

0 commit comments

Comments
 (0)