Skip to content

Commit 0de9751

Browse files
author
Pretty Taruvinga
committed
Add i ProperFraction function with tests
1 parent 6f5bc6a commit 0de9751

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

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

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (denominator === 0) return false;
15+
return Math.abs(numerator) < Math.abs(denominator);
1516
}
16-
17+
//
1718
// The line below allows us to load the isProperFraction function into tests in other files.
1819
// This will be useful in the "rewrite tests with jest" step.
1920
module.exports = isProperFraction;
@@ -31,3 +32,9 @@ function assertEquals(actualOutput, targetOutput) {
3132

3233
// Example: 1/2 is a proper fraction
3334
assertEquals(isProperFraction(1, 2), true);
35+
assertEquals(isProperFraction(2, 1), false);
36+
assertEquals(isProperFraction(-1, 2), true);
37+
assertEquals(isProperFraction(1, -2), true);
38+
assertEquals(isProperFraction(-1, -2), true);
39+
assertEquals(isProperFraction(0, 2), true);
40+
assertEquals(isProperFraction(2, 0), false);

0 commit comments

Comments
 (0)