Skip to content

Commit f519980

Browse files
committed
Refactor isProperFraction to use absolute values for numerator and denominator; update tests for negative fractions
1 parent a5e2e07 commit f519980

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function isProperFraction(numerator, denominator) {
2-
if (numerator < denominator) {
2+
if (Math.abs(numerator) < Math.abs(denominator)) {
33
return true;
44
} else {
55
return false;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
44

55
test("should return true for a proper fraction", () => {
66
expect(isProperFraction(2, 3)).toEqual(true);
7+
expect(isProperFraction(4, -5)).toEqual(true);
78
});
89

910
// Case 2: Identify Improper Fractions:
@@ -12,7 +13,7 @@ test("should return false for an improper fraction", () => {
1213
});
1314

1415
// Case 3: Identify Negative Fractions:
15-
test("should return false for a negative fraction", () => {
16+
test("should return true for a negative fraction", () => {
1617
expect(isProperFraction(-3, 4)).toEqual(true);
1718
});
1819

0 commit comments

Comments
 (0)