|
10 | 10 | function isProperFraction(numerator, denominator) { |
11 | 11 | if (numerator < denominator) { |
12 | 12 | return true; |
| 13 | + }else if (numerator >= denominator) { |
| 14 | + return false; |
13 | 15 | } |
14 | 16 | } |
15 | 17 |
|
@@ -47,13 +49,21 @@ 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 | +// Zero Numerator check: |
| 65 | +// Input: numerator = 0, denominator = 5 |
| 66 | +// target output: true |
| 67 | +// Explanation: The fraction 0/5 is a proper fraction because the numerator (0) is less than the denominator (5). The function should return true. |
| 68 | +const zeroNumerator = isProperFraction(0, 5); |
| 69 | +assertEquals(zeroNumerator, true); |
0 commit comments