Skip to content

Commit 85a7125

Browse files
committed
implement isProperFraction with tests for positive, negative, equal numerator cases
and add stretch scenarios for isProperFraction edge case testing
1 parent 4723bb9 commit 85a7125

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 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+
// Use absolute value of numerator to handle negatives
1112
if (numerator < denominator) return true;
13+
return false; // for all other cases
1214
}
1315

1416
// here's our helper again
@@ -40,14 +42,28 @@ 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);
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);
50-
// ====> complete with your assertion
52+
assertEquals(equalFraction, false);
5153

5254
// Stretch:
5355
// What other scenarios could you test for?
56+
57+
// Other scenarios to test could include:
58+
59+
// Cases where the numerator or denominator is zero (e.g., 0/5, 5/0) —
60+
// especially to check for division by zero or invalid fractions.
61+
62+
// Fractions with negative denominators (e.g., 3/-4)
63+
// to see if the function handles sign correctly.
64+
65+
// Very large numbers
66+
// to check if the function works with large integers.
67+
68+
// Non-integer inputs (e.g., decimals or strings)
69+
// to test input validation (if applicable).

0 commit comments

Comments
 (0)