|
8 | 8 | // write one test at a time, and make it pass, build your solution up methodically |
9 | 9 |
|
10 | 10 | function isProperFraction(numerator, denominator) { |
11 | | - if (numerator < denominator) { |
12 | | - return true; |
13 | | - } |
| 11 | + if (numerator < denominator) return true; |
| 12 | + else return false; |
14 | 13 | } |
15 | 14 |
|
16 | | -// The line below allows us to load the isProperFraction function into tests in other files. |
17 | | -// This will be useful in the "rewrite tests with jest" step. |
18 | | -module.exports = isProperFraction; |
19 | | - |
20 | 15 | // here's our helper again |
21 | 16 | function assertEquals(actualOutput, targetOutput) { |
22 | 17 | console.assert( |
@@ -47,13 +42,15 @@ assertEquals(improperFraction, false); |
47 | 42 | // 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 | 43 | const negativeFraction = isProperFraction(-4, 7); |
49 | 44 | // ====> complete with your assertion |
| 45 | +assertEquals(properFraction, true); |
50 | 46 |
|
51 | 47 | // Equal Numerator and Denominator check: |
52 | 48 | // Input: numerator = 3, denominator = 3 |
53 | 49 | // target output: false |
54 | 50 | // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. |
55 | 51 | const equalFraction = isProperFraction(3, 3); |
56 | 52 | // ====> complete with your assertion |
| 53 | +assertEquals(equalFraction, false) |
57 | 54 |
|
58 | 55 | // Stretch: |
59 | 56 | // What other scenarios could you test for? |
0 commit comments