hope

Finished
88 * @param {...number} sides
99 */
1010 constructor(...sides) {
11 throw new Error('Remove this line and implement the function');
11 // Edge Case: Not enough sides provided
12 if (sides.length !== 3) {
13 throw new Error('Triangle must have exactly 3 sides');
14 }
15
16 // Edge Case: Non-numeric values
17 if (sides.some(side => typeof side !== 'number')) {
18 throw new Error('All sides must be numbers');
19 }
20
21 this.sides = sides;
1222 }
1323
1424 /**
1525 * @returns {boolean}
1626 */
1727 get isEquilateral() {
18 throw new Error('Remove this line and implement the function');
28 const [a, b, c] = this.sides;
29
30 // Edge Case: Invalid triangle (sides <= 0)
31 if (a <= 0 || b <= 0 || c <= 0) {
32 return false;
33 }
34
35 // Edge Case: Triangle inequality violation
36 if (!(a + b >= c && b + c >= a && a + c >= b)) {
37 return false;
38 }
39
40 return a === b && b === c;
1941 }
2042
2143 /**
2244 * @returns {boolean}
2345 */
2446 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
47 const [a, b, c] = this.sides;
48
49 // Edge Case: Invalid triangle (sides <= 0)
50 if (a <= 0 || b <= 0 || c <= 0) {
51 return false;
52 }
53
54 // Edge Case: Triangle inequality violation
55 if (!(a + b >= c && b + c >= a && a + c >= b)) {
56 return false;
57 }
58
59 return a === b || b === c || a === c;
2660 }
2761
2862 /**
2963 * @returns {boolean}
3064 */
3165 get isScalene() {
32 throw new Error('Remove this line and implement the function');
66 const [a, b, c] = this.sides;
67
68 // Edge Case: Invalid triangle (sides <= 0)
69 if (a <= 0 || b <= 0 || c <= 0) {
70 return false;
71 }
72
73 // Edge Case: Triangle inequality violation
74 if (!(a + b >= c && b + c >= a && a + c >= b)) {
75 return false;
76 }
77
78 return a !== b && b !== c && a !== c;
3379 }
3480}
81
82// Handled Edge Cases: Not enough sides provided, Non-numeric values, Invalid triangle (sides <= 0), Triangle inequality violation
Test NameStatus
all sides are equal
Pass
any side is unequal
Pass
no sides are equal
Pass
all zero sides is not a triangle
Pass
sides may be floats
Pass
last two sides are equal
Pass
first two sides are equal
Pass
first and last sides are equal
Pass
equilateral triangles are also isosceles
Pass
no sides are equal
Pass
first triangle inequality violation
Pass
second triangle inequality violation
Pass
third triangle inequality violation
Pass
sides may be floats
Pass
no sides are equal
Pass
all sides are equal
Pass
first and second sides are equal
Pass
first and third sides are equal
Pass
second and third sides are equal
Pass
may not violate triangle inequality
Pass
sides may be floats
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.