Skip to content

Commit 488330c

Browse files
enhance isProperFraction function to handle incomplete and invalid inputs
1 parent 6dc114e commit 488330c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
if (!numerator || !denominator) return "Incomplete fraction";
14+
if (numerator === undefined || denominator === undefined)
15+
return "Incomplete fraction";
1516
if (typeof numerator !== "number" || typeof denominator !== "number")
1617
return "Use only numbers";
18+
if (denominator === 0) return false;
1719

1820
return Math.abs(numerator) < Math.abs(denominator);
1921
}
@@ -93,7 +95,6 @@ assertEquals(notANumber, "Use only numbers");
9395
const notANumber2 = isProperFraction(7, "q");
9496
assertEquals(notANumber2, "Use only numbers");
9597

96-
9798
//Incomplete input
9899
//Input:2
99100
// target output: message

0 commit comments

Comments
 (0)