Skip to content

Commit 56f0660

Browse files
committed
implement 2
1 parent 0e757a7 commit 56f0660

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ assertEquals(getAngleType(-10), "Invalid angle");
7070
assertEquals(getAngleType(360), "Invalid angle");
7171
assertEquals(getAngleType(361), "Invalid angle");
7272

73-
console.log("All tests executed (any failures would appear above).");
73+
console.log("All tests passed!");

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
15+
if (denominator === 0) return false;
16+
if (denominator < 0) return false;
17+
18+
return Math.abs(numerator) < denominator;
1519
}
1620

1721
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,3 +35,24 @@ function assertEquals(actualOutput, targetOutput) {
3135

3236
// Example: 1/2 is a proper fraction
3337
assertEquals(isProperFraction(1, 2), true);
38+
39+
// Improper fractions (numerator > denominator)
40+
assertEquals(isProperFraction(2, 1), false);
41+
assertEquals(isProperFraction(5, 4), false);
42+
43+
// Equal numerator/denominator is not proper
44+
assertEquals(isProperFraction(5, 5), false);
45+
46+
// Zero numerator:
47+
assertEquals(isProperFraction(0, 3), true);
48+
49+
// Negative numerator:
50+
assertEquals(isProperFraction(-1, 2), true);
51+
assertEquals(isProperFraction(-3, 2), false);
52+
53+
// Denominator edge cases
54+
assertEquals(isProperFraction(1, 0), false);
55+
assertEquals(isProperFraction(1, -2), false);
56+
assertEquals(isProperFraction(-1, -2), false);
57+
58+
console.log ("All tests passed!")

0 commit comments

Comments
 (0)