Skip to content

Commit 56ccaef

Browse files
committed
Removed redundant code and add condition for negative nemurator and denominator.
1 parent a0cf3ae commit 56ccaef

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

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

1010
function isProperFraction(numerator, denominator) {
11-
if (Math.abs(numerator) < denominator) return true; // This version of code works correctly for proper and negative fractions.
11+
if (Math.abs(numerator) < Math.abs(denominator)) return true; // This version of code works correctly for proper and negative fractions.
1212
if (Math.abs(numerator) >= Math.abs(denominator)) return false;
1313
if (Math.abs(numerator) === Math.abs(denominator)) return false;
1414

15-
if (numerator < denominator) {
16-
return true;
17-
}
15+
// if (numerator < denominator) {
16+
// return true;
17+
// }
1818

1919
}
2020

@@ -66,3 +66,5 @@ assertEquals(equalFraction, false); // assertion for equal numerator and denomin
6666
console.log(isProperFraction(5, 2));
6767
console.log(isProperFraction(-4, 7));
6868
console.log(isProperFraction(-3, 3));
69+
console.log(isProperFraction(-2, -3)); // This is a proper fraction because the absolute value of numerator 2 and denominator is 3.
70+
// the value of numerator is less than denominator.

0 commit comments

Comments
 (0)