Skip to content

Commit 63dc46f

Browse files
author
kohanman
committed
Sprint 3 | Coursework 1.2
1 parent 419c9ba commit 63dc46f

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
@@ -8,9 +8,9 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11-
if (numerator < denominator) {
11+
if (Math.abs(numerator) < Math.abs(denominator)) {
1212
return true;
13-
}
13+
} else return false;
1414
}
1515

1616
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -46,14 +46,19 @@ assertEquals(improperFraction, false);
4646
// target output: true
4747
// 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.
4848
const negativeFraction = isProperFraction(-4, 7);
49-
// ====> complete with your assertion
49+
assertEquals(negativeFraction, true);
5050

5151
// Equal Numerator and Denominator check:
5252
// Input: numerator = 3, denominator = 3
5353
// target output: false
5454
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
5555
const equalFraction = isProperFraction(3, 3);
56-
// ====> complete with your assertion
56+
assertEquals(equalFraction, false);
5757

5858
// Stretch:
5959
// What other scenarios could you test for?
60+
const doublenegativeFraction = isProperFraction(-3, -5);
61+
assertEquals(doublenegativeFraction, true);
62+
63+
const zeronumeratorFraction = isProperFraction(0, 4);
64+
assertEquals(zeronumeratorFraction, true);

0 commit comments

Comments
 (0)