Skip to content

Commit eed725e

Browse files
authored
Update 2-is-proper-fraction.js
add condition to heck if denominator is zero
1 parent 7c6010a commit eed725e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sprint-3/1-key-implement/2-is-proper-fraction.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11+
if (denominator === 0) {
12+
// Denominator can't be zero in a valid fraction
13+
return false;
14+
}
1115
// if (numerator < denominator) return true; it will not work for negative numbers
1216
return Math.abs(numerator) < Math.abs(denominator);
1317
}

0 commit comments

Comments
 (0)