Skip to content

Commit 1154f89

Browse files
committed
Add else condition to simplify my code.
1 parent fad2100 commit 1154f89

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
function isProperFraction(numerator, denominator) {
2-
if (Math.abs(numerator) < Math.abs(denominator)) return true; // This version of code works correctly for proper and negative fractions.
3-
if (Math.abs(numerator) >= Math.abs(denominator)) return false;
4-
if (Math.abs(numerator) === Math.abs(denominator)) return false;
2+
if (denominator === 0) {
3+
return false;
4+
} else if (Math.abs(numerator) < Math.abs(denominator)) {
5+
return true;
6+
} else {
7+
return false;
8+
}
59
}
610

11+
// This version of code works correctly for proper and negative fractions.
712
module.exports = isProperFraction;

0 commit comments

Comments
 (0)