Skip to content

Commit 0741973

Browse files
committed
Fractions fixed now negitave numbers are handled test are more robust
1 parent 2cd0d86 commit 0741973

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
14+
numerator = Math.sign(numerator) * Math.abs(numerator);
1515
return (numerator < denominator )
1616
}
1717

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ test(`should return false when the (numerator > denominator)`,()=>{
2121
test(`Should return a true when the (numerator < denominator)`,()=>{
2222
expect(isProperFraction(1,2)).toEqual(true)
2323
expect(isProperFraction(6,8)).toEqual(true)
24-
expect(isProperFraction(-3,2)).toEqual(true)
24+
expect(isProperFraction(-1,2)).toEqual(true)
2525
});
26+
test(`Should return the correct answer for negative numerators (numerator < denominator)`,()=>{
27+
expect(isProperFraction(-1,2)).toEqual(true)
28+
expect(isProperFraction(-100,2)).toEqual(true)
29+
expect(isProperFraction(-7,8)).toEqual(true)
2630

31+
});

0 commit comments

Comments
 (0)