Skip to content

Commit 4e519a1

Browse files
committed
refactor isProperFraction function to enhance checks for acceptance scenarios 3 & 4
1 parent d40b0a5 commit 4e519a1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ function isProperFraction(numerator, denominator) {
1414
if (numerator >= denominator) {
1515
return false;
1616
}
17-
if(numerator == 0 && denominator !== 0){
17+
if (numerator == 0 && denominator !== 0) {
1818
return true;
1919
}
2020
if (denominator === 0) {
2121
return false;
2222
}
23+
if (numerator == denominator) {
24+
return false;
25+
}
26+
if (numerator < 0 && denominator > 0 && Math.abs(numerator) < denominator) {
27+
return true;
28+
}
2329
}
24-
2530
// The line below allows us to load the isProperFraction function into tests in other files.
2631
// This will be useful in the "rewrite tests with jest" step.
2732
module.exports = isProperFraction;
@@ -74,7 +79,7 @@ const zeroNumerator = isProperFraction(0, 5);
7479
// ====> complete with your assertion
7580
assertEquals(zeroNumerator, true);
7681
// Zero Denominator check:
77-
// Input: numerator = 4, denominator = 0
82+
// Input: numerator = 4, denominator = 0
7883
// target output: false
7984
// Explanation: The fraction 4/0 is undefined because division by zero is not allowed. The function should return false.
8085
const zeroDenominator = isProperFraction(4, 0);
@@ -100,4 +105,4 @@ assertEquals(bothNegative, true);
100105
// Explanation: The fraction 0/0 is undefined. The function should return false.
101106
const zeroNumeratorDenominator = isProperFraction(0, 0);
102107
// ====> complete with your assertion
103-
assertEquals(zeroNumeratorDenominator, false);
108+
assertEquals(zeroNumeratorDenominator, false);

0 commit comments

Comments
 (0)