Skip to content

Commit a73fa1a

Browse files
committed
Completed 2-is-proper-fraction
1 parent 1924ef4 commit a73fa1a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
15+
if (denominator === 0) return false;
16+
return Math.abs(numerator) < Math.abs(denominator);
1517
}
1618

1719
// The line below allows us to load the isProperFraction function into tests in other files.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,18 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
test(`for positive`, () => {
13+
expect(isProperFraction(6, 7)).toEqual(true);
14+
expect(isProperFraction(2, 4)).toEqual(true);
15+
});
16+
17+
test(`should return false for improper fractions`, () => {
18+
expect(isProperFraction(8, 6)).toEqual(false);
19+
expect(isProperFraction(4, 2)).toEqual(false);
20+
});
21+
22+
test(`negative combinations`, () => {
23+
expect(isProperFraction(-5, 9)).toEqual(true);
24+
expect(isProperFraction(-2, 0)).toEqual(false);
25+
});

0 commit comments

Comments
 (0)