|
9 | 9 |
|
10 | 10 | function isProperFraction(numerator, denominator) { |
11 | 11 | if (numerator < denominator) { |
12 | | - return true; |
| 12 | + return true ; |
| 13 | + } |
| 14 | + else { |
| 15 | + return false; |
13 | 16 | } |
14 | 17 | } |
15 | 18 |
|
@@ -38,22 +41,29 @@ assertEquals(properFraction, true); |
38 | 41 | // Input: numerator = 5, denominator = 2 |
39 | 42 | // target output: false |
40 | 43 | // Explanation: The fraction 5/2 is an improper fraction, where the numerator is greater than or equal to the denominator. The function should return false. |
41 | | -const improperFraction = isProperFraction(5, 2); |
42 | | -assertEquals(improperFraction, false); |
| 44 | +const properFraction2 = isProperFraction(5, 2); |
| 45 | +assertEquals(properFraction2, false); |
43 | 46 |
|
44 | 47 | // Negative Fraction check: |
45 | 48 | // Input: numerator = -4, denominator = 7 |
46 | 49 | // target output: true |
47 | 50 | // 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 | 51 | const negativeFraction = isProperFraction(-4, 7); |
| 52 | +assertEquals(negativeFraction, true); |
49 | 53 | // ====> complete with your assertion |
50 | 54 |
|
51 | 55 | // Equal Numerator and Denominator check: |
52 | 56 | // Input: numerator = 3, denominator = 3 |
53 | 57 | // target output: false |
54 | 58 | // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. |
55 | 59 | const equalFraction = isProperFraction(3, 3); |
56 | | -// ====> complete with your assertion |
| 60 | +assertEquals(equalFraction, false); |
57 | 61 |
|
58 | 62 | // Stretch: |
59 | 63 | // What other scenarios could you test for? |
| 64 | + |
| 65 | +const properFraction3 = isProperFraction(0, 6); |
| 66 | +assertEquals(properFraction3,true) |
| 67 | + |
| 68 | +const properFraction4 = isProperFraction(0, 1); |
| 69 | +assertEquals(properFraction4, true); |
0 commit comments