Skip to content

Commit caaac8f

Browse files
add Math.abs for negative value
1 parent 6f511b3 commit caaac8f

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,18 @@ test("Equal numerator and denominator", () => {
2020
// Example: equal number
2121
assert.equal(isProperFraction(5, 5), false);
2222
});
23+
24+
test("zero numerator", () => {
25+
// Example: zero numerator is a proper fraction?
26+
assert.equal(isProperFraction(0, 6), true);
27+
});
28+
29+
test("Negative numerator", () => {
30+
// Example: negative numerator is a proper fraction?
31+
assert.equal(isProperFraction(-2, 3), true);
32+
});
33+
34+
test("Negative denominator", () => {
35+
// Example: negative numerator is a proper fraction?
36+
assert.equal(isProperFraction(2, -5), true);
37+
});

‎implement-and-rewrite-tests/implement/2-is-proper-fraction.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
export function isProperFraction(numerator, denominator) {
1717
// TODO: Implement this function
18-
if (numerator < denominator) {
18+
if (Math.abs(numerator) < Math.abs(denominator)) {
1919
return true;
2020
}
2121
return false;

0 commit comments

Comments
 (0)