Skip to content

Commit 29b6533

Browse files
committed
Implement isProperFraction with full test coverage
1 parent 6998ca1 commit 29b6533

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

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

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (Math.abs(numerator) < Math.abs(denominator)) {
15+
return true;
16+
} else {
17+
return false;
18+
}
1519
}
20+
// TODO: Implement this function
1621

1722
// The line below allows us to load the isProperFraction function into tests in other files.
1823
// This will be useful in the "rewrite tests with jest" step.
@@ -31,3 +36,13 @@ function assertEquals(actualOutput, targetOutput) {
3136

3237
// Example: 1/2 is a proper fraction
3338
assertEquals(isProperFraction(1, 2), true);
39+
40+
assertEquals(isProperFraction(3, 2), false);
41+
42+
assertEquals(isProperFraction(2, 2), false);
43+
44+
assertEquals(isProperFraction(-1, 2), true);
45+
46+
assertEquals(isProperFraction(1, -2), true);
47+
48+
assertEquals(isProperFraction(-1, -2), true);

0 commit comments

Comments
 (0)