Skip to content

Commit 6b4ee50

Browse files
committed
implement isproperfraction function and rewrite tests to cover all cases
1 parent 4a2804d commit 6b4ee50

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

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

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

3236
// Example: 1/2 is a proper fraction
3337
assertEquals(isProperFraction(1, 2), true);
38+
// Example: 2/1 is not a proper fraction
39+
assertEquals(isProperFraction(2, 1), false);
40+
// Example: 1/2 is a proper fraction
41+
assertEquals(isProperFraction(-1, 2), true);
42+
// Example: -1/2 is a proper fraction
43+
assertEquals(isProperFraction(-1, -2), true);
44+
// Example: 1/2 is a proper fraction
45+
assertEquals(isProperFraction(1, -2), true);
46+
// Example: -2/1 is not a proper fraction
47+
assertEquals(isProperFraction(-2, 1), false);
48+
// Example: 1/2 is not a proper fraction
49+
assertEquals(isProperFraction(-2, -1), false);

0 commit comments

Comments
 (0)