|
10 | 10 | function isProperFraction(numerator, denominator) { |
11 | 11 | if (numerator < denominator) { |
12 | 12 | return true; |
| 13 | + } else { |
| 14 | + return false; |
13 | 15 | } |
14 | 16 | } |
15 | 17 |
|
@@ -47,13 +49,29 @@ assertEquals(improperFraction, false); |
47 | 49 | // 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. |
48 | 50 | const negativeFraction = isProperFraction(-4, 7); |
49 | 51 | // ====> complete with your assertion |
| 52 | +assertEquals(negativeFraction, true); |
50 | 53 |
|
51 | 54 | // Equal Numerator and Denominator check: |
52 | 55 | // Input: numerator = 3, denominator = 3 |
53 | 56 | // target output: false |
54 | 57 | // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. |
55 | 58 | const equalFraction = isProperFraction(3, 3); |
56 | 59 | // ====> complete with your assertion |
| 60 | +assertEquals(equalFraction, false); |
57 | 61 |
|
58 | 62 | // Stretch: |
59 | 63 | // 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