Skip to content

Commit ac08757

Browse files
committed
// Sprint-3-implement 1-is-proper-fraction.js all assertions and necessary functions added
1 parent f723809 commit ac08757

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ function isProperFraction(numerator, denominator) {
1111
if (numerator < denominator) {
1212
return true;
1313
}
14+
else if (numerator > denominator){
15+
return false;
16+
}
17+
else if (numerator === denominator) {
18+
return false;
19+
}
20+
else if (numerator === 0){
21+
retrurn (false);
22+
}
23+
else if (denominator === 0){
24+
return (false);
25+
}
1426
}
1527

1628
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -46,14 +58,24 @@ assertEquals(improperFraction, false);
4658
// target output: true
4759
// 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.
4860
const negativeFraction = isProperFraction(-4, 7);
49-
// ====> complete with your assertion
61+
assertEquals(negativeFraction, true);
5062

5163
// Equal Numerator and Denominator check:
5264
// Input: numerator = 3, denominator = 3
5365
// target output: false
5466
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5567
const equalFraction = isProperFraction(3, 3);
68+
assertEquals(equalFraction, false);
5669
// ====> complete with your assertion
5770

5871
// Stretch:
5972
// What other scenarios could you test for?
73+
74+
const numeratorZero = isProperFraction(0, 5);
75+
assertEquals(numeratorZero, true);
76+
77+
const denominatorrZero = isProperFraction(5, 0);
78+
assertEquals(denominatorrZero, false);
79+
80+
// Sprint-3-implement 1-is-proper-fraction.js all assertions and necessary functions added
81+

0 commit comments

Comments
 (0)