Skip to content

Commit debd986

Browse files
author
Baba05206
committed
Refactor isProperFraction function to improve zero denominator handling and simplify logic for proper fraction checks
1 parent 30ac3b1 commit debd986

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
function isProperFraction(numerator, denominator) {
1111
if (denominator === 0) {
1212
return "Invalid — denominator cannot be zero";
13-
} else if (numerator * numerator < denominator * denominator) {
14-
return true;
15-
} else {
16-
return false;
1713
}
14+
15+
return Math.abs(numerator) < Math.abs(denominator);
1816
}
1917

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

0 commit comments

Comments
 (0)