Skip to content

Commit e110722

Browse files
committed
2-is-proper-fraction update case
1 parent a7b7c2f commit e110722

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ function isProperFraction(numerator, denominator) {
1414
if (numerator >= denominator) {
1515
return false;
1616
}
17+
if (Math.abs(numerator) < Math.abs(denominator)) {
18+
return true;
19+
}
20+
if (Math.abs(numerator) >= Math.abs(denominator)) {
21+
return false;
22+
}
1723
}
1824

1925
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -49,14 +55,23 @@ assertEquals(improperFraction, false);
4955
// target output: true
5056
// 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.
5157
const negativeFraction = isProperFraction(-4, 7);
58+
assertEquals(negativeFraction, true);
5259
// ====> complete with your assertion
5360

5461
// Equal Numerator and Denominator check:
5562
// Input: numerator = 3, denominator = 3
5663
// target output: false
5764
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5865
const equalFraction = isProperFraction(3, 3);
66+
assertEquals(equalFraction, false);
5967
// ====> complete with your assertion
6068

6169
// Stretch:
6270
// What other scenarios could you test for?
71+
// Zero Numerator check:
72+
// Input: numerator = 0, denominator = 5
73+
// target output: true
74+
// Explanation: The fraction 0/5 is a proper fraction because the numerator (0) is less than the denominator (5). The function should return true.
75+
const zeroNumerator = isProperFraction(0, 5);
76+
assertEquals(zeroNumerator, true);
77+

0 commit comments

Comments
 (0)