Skip to content

Commit 0cba6bb

Browse files
committed
Completed the rest the tests and cases
1 parent 532fd66 commit 0cba6bb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sprint-3/1-key-implement/2-is-proper-fraction.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11-
if (numerator < denominator) return true;
11+
if (Math.abs(numerator) < denominator) return true; // This version of code works correctly for proper and negative fractions.
12+
if (Math.abs(numerator) >= Math.abs(denominator)) return false;
13+
if (Math.abs(numerator) === Math.abs(denominator)) return false;
1214
}
1315

1416
// here's our helper again
@@ -40,13 +42,14 @@ assertEquals(improperFraction, false);
4042
// target output: true
4143
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
4244
const negativeFraction = isProperFraction(-4, 7);
43-
// ====> complete with your assertion
45+
assertEquals(negativeFraction, true); // assertion for negative fraction.
4446

4547
// Equal Numerator and Denominator check:
4648
// Input: numerator = 3, denominator = 3
4749
// target output: false
4850
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
4951
const equalFraction = isProperFraction(3, 3);
52+
assertEquals(equalFraction, false); // assertion for equal numerator and denominator.
5053
// ====> complete with your assertion
5154

5255
// Stretch:

0 commit comments

Comments
 (0)