Skip to content

Commit 7dc44ec

Browse files
fix: update isProperFraction function logic and add missing assertion
1 parent ca08ca9 commit 7dc44ec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11-
if (numerator < denominator) return true;
12-
else return false;
11+
if (denominator === 0) {
12+
throw new Error();
13+
}
14+
return Math.abs(numerator) < Math.abs(denominator);
1315
}
1416

1517
// here's our helper again
@@ -50,7 +52,7 @@ assertEquals(properFraction, true);
5052
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5153
const equalFraction = isProperFraction(3, 3);
5254
// ====> complete with your assertion
53-
assertEquals(equalFraction, false)
55+
assertEquals(equalFraction, false);
5456

5557
// Stretch:
5658
// What other scenarios could you test for?

0 commit comments

Comments
 (0)