Skip to content

Commit 87fc686

Browse files
committed
Update: test isProperFraction function is correct and reintroduce usage examples
1 parent 0a7cda4 commit 87fc686

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
const isProperFraction = require("./2-is-proper-fraction");
1+
function isProperFraction(numerator, denominator) {
2+
// Case 1: Check for zero denominator (undefined)
3+
if (denominator === 0) return false;
24

3-
test("should return true for a proper fraction", () => {
4-
expect(isProperFraction(2, 3)).toEqual(true);
5-
});
5+
// Case 2: Check for negative values (numerator or denominator)
6+
if (numerator < 0 || denominator < 0) return false;
67

7-
// Case 2: Identify Improper Fractions:
8+
// Case 3: Check for equal numerator and denominator
9+
if (numerator === denominator) return false;
810

9-
// Case 3: Identify Negative Fractions:
11+
// Case 4: Check for proper fraction (numerator < denominator)
12+
return numerator < denominator;
13+
}
14+
module.exports = isProperFraction;
15+
// usage examples
16+
console.log(isProperFraction(2, 3)); // true
17+
console.log(isProperFraction(5, 3)); // false
18+
console.log(isProperFraction(3, 3)); // false
19+
console.log(isProperFraction(-2, 3)); // false
20+
console.log(isProperFraction(2, -3)); // false
21+
console.log(isProperFraction(0, 5)); // true (0 < 5)
22+
console.log(isProperFraction(2, 2)); // false
1023

11-
// Case 4: Identify Equal Numerator and Denominator:
24+
// Test cases for the isProperFraction function
25+
// test("should return true for a proper fraction", () => {
26+
// expect(isProperFraction(2, 3)).toEqual(true);
27+
// });

0 commit comments

Comments
 (0)