Skip to content

Commit 735b51d

Browse files
simplify function
1 parent fe8068f commit 735b51d

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test("Negative numerator", () => {
3232
});
3333

3434
test("Negative denominator", () => {
35-
// Example: negative numerator is a proper fraction?
35+
// Example: negative denominator is a proper fraction?
3636
assert.equal(isProperFraction(2, -5), true);
3737
});
3838

@@ -41,3 +41,18 @@ test("Both negative", () => {
4141
assert.equal(isProperFraction(-3, -5), true);
4242
assert.equal(isProperFraction(-5, -2), false);
4343
});
44+
45+
test("Zero denominator", () => {
46+
// Example: Zero denominator is a proper fraction?
47+
assert.equal(isProperFraction(7, 0), false);
48+
});
49+
50+
test("Zero numerator and negative denominator", () => {
51+
// Example: Zero numerator and negative denominator is a proper fraction?
52+
assert.equal(isProperFraction(0, -7), true);
53+
});
54+
55+
test("Both Zero", () => {
56+
// Example: Both Zero is a proper fraction?
57+
assert.equal(isProperFraction(0, 0), false);
58+
});

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@
1515

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

0 commit comments

Comments
 (0)