Skip to content

Commit 0de42f1

Browse files
committed
proper fraction sorted.
1 parent 3eff2ca commit 0de42f1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Sprint-3/1-key-implement/2-is-proper-fraction.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
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) return true;
11+
if (Math.abs(numerator) < Math.abs(denominator)) {
12+
return true;
13+
} else {
14+
return false;
15+
}
1216
}
1317

1418
// here's our helper again
1519
function assertEquals(actualOutput, targetOutput) {
1620
console.assert(
1721
actualOutput === targetOutput,
18-
`Expected ${actualOutput} to equal ${targetOutput}`
22+
Expected ${actualOutput} to equal ${targetOutput}
1923
);
2024
}
2125

@@ -40,14 +44,14 @@ assertEquals(improperFraction, false);
4044
// target output: true
4145
// 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.
4246
const negativeFraction = isProperFraction(-4, 7);
43-
// ====> complete with your assertion
47+
assertEquals(negativeFraction, true);
4448

4549
// Equal Numerator and Denominator check:
4650
// Input: numerator = 3, denominator = 3
4751
// target output: false
4852
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
4953
const equalFraction = isProperFraction(3, 3);
50-
// ====> complete with your assertion
54+
assertEquals(equalFraction, false);
5155

5256
// Stretch:
53-
// What other scenarios could you test for?
57+
// What other scenarios could you test for?

0 commit comments

Comments
 (0)