Skip to content

Commit 01079c2

Browse files
committed
Update Sprint-3\2\2-is-proper-fraction.js
1 parent 95332ed commit 01079c2

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
function isProperFraction(numerator, denominator) {
22
if (numerator < denominator) return true;
33
// add your completed function from key-implement here
4+
//return denominator !== 0 && Math.abs(numerator) < Math.abs(denominator);
5+
if (denominator === 0) return false; // Avoid division by zero
6+
if (numerator === 0) return true; // Zero is considered a proper fraction
7+
if (numerator < 0 || denominator < 0) return false; // Negative fractions are not proper
8+
return Math.abs(numerator) < Math.abs(denominator);
9+
10+
411
}
512

6-
module.exports = isProperFraction;
13+
console.log(isProperFraction(0, 1));
14+
15+
module.exports = isProperFraction;
16+

Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@ const isProperFraction = require("./2-is-proper-fraction");
22

33
test("should return true for a proper fraction", () => {
44
expect(isProperFraction(2, 3)).toEqual(true);
5+
expect(isProperFraction(1, 2)).toEqual(true);
56
});
67

78
// Case 2: Identify Improper Fractions:
9+
test("should return false for an improper fraction", () => {
10+
expect(isProperFraction(5, 3)).toEqual(false);
11+
expect(isProperFraction(3, 3)).toEqual(false);
12+
});
13+
814

915
// Case 3: Identify Negative Fractions:
16+
test("should return false for a negative fraction", () => {
17+
//expect(isProperFraction(-2, 3)).toEqual(false);
18+
expect(isProperFraction(2, -3)).toEqual(false);
19+
expect(isProperFraction(-2, -3)).toEqual(false); // consider your spec on this one
20+
});
21+
22+
23+
1024

11-
// Case 4: Identify Equal Numerator and Denominator:

0 commit comments

Comments
 (0)