Skip to content

Commit c45cf70

Browse files
committed
Fixed wrong if-statements in the 2-is-proper-fraction.js
1 parent 878ee90 commit c45cf70

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
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) {
12-
return true;
13-
}
14-
if (numerator > denominator) {
11+
if (denominator === 0) {
1512
return false;
1613
}
17-
if (numerator === denominator) {
18-
return false;
14+
if (Math.abs(numerator) < Math.abs(denominator)) {
15+
return true;
1916
}
17+
return false;
2018
}
2119

2220
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -69,7 +67,7 @@ assertEquals(equalFraction, false);
6967
// target output: false
7068
// Explanation: The fraction -4/-9 is equivalent to 4/9, which is a proper fraction. Function should return false.
7169
const bothNegative = isProperFraction(-4, -9);
72-
assertEquals(bothNegative, false);
70+
assertEquals(bothNegative, true);
7371

7472
// Zero Numerator check:
7573
// Input: numerator = 0, denominator = 7

0 commit comments

Comments
 (0)