You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/implement/is-proper-fraction.js
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,32 @@
25
25
// Negative Fraction check:
26
26
// Input: numerator = -4, denominator = 7
27
27
// target output: true
28
-
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
28
+
// Explanation: The fraction -4/7 is a proper fraction because
29
+
// the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
29
30
30
31
// Equal Numerator and Denominator check:
31
32
// Input: numerator = 3, denominator = 3
32
33
// target output: false
33
34
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
34
35
// These acceptance criteria cover a range of scenarios to ensure that the isProperFraction function handles both proper and improper fractions correctly and handles potential errors such as a zero denominator.
36
+
37
+
functionisProperFraction(numerator,denominator){
38
+
// Check for denominator being zero
39
+
if(denominator===0){
40
+
thrownewError("Denominator cannot be zero");
41
+
}
42
+
43
+
// If numerator is equal to denominator, it's not a proper fraction
44
+
if(numerator===denominator){
45
+
returnfalse;
46
+
}
47
+
48
+
// Proper fraction if the absolute value of the numerator is less than the denominator
0 commit comments