Skip to content

Commit 61f0da7

Browse files
committed
created test cases for fractions and tested them
1 parent 3cbfc96 commit 61f0da7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
function isProperFraction(numerator, denominator) {
1111
if (numerator < denominator) {
1212
return true;
13+
}else if (numerator >= denominator) {
14+
return false;
1315
}
1416
}
1517

@@ -47,13 +49,21 @@ assertEquals(improperFraction, false);
4749
// 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.
4850
const negativeFraction = isProperFraction(-4, 7);
4951
// ====> complete with your assertion
52+
assertEquals(negativeFraction, true);
5053

5154
// Equal Numerator and Denominator check:
5255
// Input: numerator = 3, denominator = 3
5356
// target output: false
5457
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5558
const equalFraction = isProperFraction(3, 3);
5659
// ====> complete with your assertion
60+
assertEquals(equalFraction, false);
5761

5862
// Stretch:
5963
// What other scenarios could you test for?
64+
// Zero Numerator check:
65+
// Input: numerator = 0, denominator = 5
66+
// target output: true
67+
// Explanation: The fraction 0/5 is a proper fraction because the numerator (0) is less than the denominator (5). The function should return true.
68+
const zeroNumerator = isProperFraction(0, 5);
69+
assertEquals(zeroNumerator, true);

0 commit comments

Comments
 (0)