Skip to content

Commit 0a7cda4

Browse files
committed
Update: test isProperFraction function to include comprehensive checks for numerator and denominator, ensuring proper fraction validation
1 parent e67b162 commit 0a7cda4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
function isProperFraction(numerator, denominator) {
2-
if (numerator < denominator) return true;
3-
// add your completed function from key-implement here
2+
if (denominator === 0) return false; // Avoid division by zero
3+
if (numerator < 0 || denominator < 0) return false; // Proper fractions are positive
4+
if (numerator < denominator) return true; // Proper if numerator < denominator
5+
return false; // Otherwise, it's improper
46
}
57

6-
module.exports = isProperFraction;
8+
module.exports = isProperFraction;
9+
// Test cases for the isProperFraction function
10+
console.log(isProperFraction(1, 2)); // true
11+
console.log(isProperFraction(3, 4)); // true
12+
console.log(isProperFraction(5, 5)); // false
13+
console.log(isProperFraction(7, 6)); // false
14+
console.log(isProperFraction(0, 1)); // true
15+
console.log(isProperFraction(1, 0)); // false (denominator is zero)
16+
console.log(isProperFraction(-1, 2)); // false (negative numerator)
17+
console.log(isProperFraction(1, -2)); // false (negative denominator)
18+
console.log(isProperFraction(-1, -2)); // false (both negative)
19+
console.log(isProperFraction(2, 3)); // true

0 commit comments

Comments
 (0)