Skip to content

Commit 2b5822f

Browse files
committed
Completed 2-is-proper-fraction.js exercise
1 parent 5f845d0 commit 2b5822f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
function isProperFraction(numerator, denominator) {
1111
if (numerator < denominator) {
1212
return true;
13+
} else {
14+
return false;
1315
}
1416
}
1517

@@ -47,13 +49,29 @@ assertEquals(improperFraction, false);
4749
// 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.
4850
const negativeFraction = isProperFraction(-4, 7);
4951
// ====> complete with your assertion
52+
assertEquals(negativeFraction, true);
5053

5154
// Equal Numerator and Denominator check:
5255
// Input: numerator = 3, denominator = 3
5356
// target output: false
5457
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5558
const equalFraction = isProperFraction(3, 3);
5659
// ====> complete with your assertion
60+
assertEquals(equalFraction, false);
5761

5862
// Stretch:
5963
// What other scenarios could you test for?
64+
65+
// Zero Numerator check:
66+
// Input: numerator = 0, denominator = 5
67+
// target output: true
68+
// Explanation: The fraction 0/5 is a proper fraction because the numerator is less than the denominator.
69+
const zeroNumerator = isProperFraction(0, 5);
70+
assertEquals(zeroNumerator, true);
71+
72+
// Zero Denominator check:
73+
// Input: numerator = 5, denominator = 0
74+
// target output: false
75+
// Explanation: The fraction 5/0 is undefined because division by zero is not allowed.
76+
const zeroDenominator = isProperFraction(5, 0);
77+
assertEquals(zeroDenominator, false);

0 commit comments

Comments
 (0)