Skip to content

Commit 6937b06

Browse files
committed
Implement isProperFraction function with basic tests
1 parent cfb55de commit 6937b06

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
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+
if(numerator===denominator){
15+
return false
16+
}
17+
if((Math.abs(numerator))<denominator){
18+
return true
19+
}
20+
if (numerator > denominator) {
21+
return false;
22+
}
23+
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,19 @@ 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);
61+
assertEquals(negativeFraction, true)
4962
// ====> complete with your assertion
5063

5164
// Equal Numerator and Denominator check:
5265
// Input: numerator = 3, denominator = 3
5366
// target output: false
5467
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5568
const equalFraction = isProperFraction(3, 3);
69+
assertEquals(equalFraction, false)
5670
// ====> complete with your assertion
5771

5872
// Stretch:
5973
// What other scenarios could you test for?
74+
const zeroDenominator= isProperFraction(2, 0);
75+
assertEquals(zeroDenominator, false)
76+

0 commit comments

Comments
 (0)