tobe

Finished
88 * @param {...number} sides
99 */
1010 constructor(...sides) {
11 throw new Error('Remove this line and implement the function');
11 // Edge Case: Invalid number of sides (not exactly 3)
12 if (sides.length !== 3) {
13 throw new Error('Triangle must have exactly 3 sides');
14 }
15
16 // Edge Case: Non-numeric sides
17 if (sides.some(side => typeof side !== 'number')) {
18 throw new Error('All sides must be numbers');
19 }
20
21 // Edge Case: NaN values
22 if (sides.some(side => isNaN(side))) {
23 throw new Error('Sides cannot be NaN');
24 }
25
26 // Edge Case: Infinite values
27 if (sides.some(side => !isFinite(side))) {
28 throw new Error('Sides cannot be infinite');
29 }
30
31 this.sides = sides;
1232 }
1333
1434 /**
1535 * @returns {boolean}
1636 */
1737 get isEquilateral() {
18 throw new Error('Remove this line and implement the function');
38 const [a, b, c] = this.sides;
39
40 // Edge Case: All sides must be positive
41 if (a <= 0 || b <= 0 || c <= 0) {
42 return false;
43 }
44
45 // Edge Case: Triangle inequality violation
46 if (!this._isValidTriangle()) {
47 return false;
48 }
49
50 return a === b && b === c;
1951 }
2052
2153 /**
2254 * @returns {boolean}
2355 */
2456 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
57 const [a, b, c] = this.sides;
58
59 // Edge Case: All sides must be positive
60 if (a <= 0 || b <= 0 || c <= 0) {
61 return false;
62 }
63
64 // Edge Case: Triangle inequality violation
65 if (!this._isValidTriangle()) {
66 return false;
67 }
68
69 return a === b || b === c || a === c;
2670 }
2771
2872 /**
2973 * @returns {boolean}
3074 */
3175 get isScalene() {
32 throw new Error('Remove this line and implement the function');
76 const [a, b, c] = this.sides;
77
78 // Edge Case: All sides must be positive
79 if (a <= 0 || b <= 0 || c <= 0) {
80 return false;
81 }
82
83 // Edge Case: Triangle inequality violation
84 if (!this._isValidTriangle()) {
85 return false;
86 }
87
88 return a !== b && b !== c && a !== c;
89 }
90
91 /**
92 * Helper method to check if the sides form a valid triangle
93 * @returns {boolean}
94 */
95 _isValidTriangle() {
96 const [a, b, c] = this.sides;
97
98 // Edge Case: All sides must be positive
99 if (a <= 0 || b <= 0 || c <= 0) {
100 return false;
101 }
102
103 // Check triangle inequality: sum of any two sides must be >= third side
104 return (a + b >= c) && (b + c >= a) && (a + c >= b);
33105 }
34106}
107
108// Handled Edge Cases: Invalid number of sides, non-numeric sides, NaN values, infinite values, negative or zero sides, triangle inequality violations
109// Handled Edge Cases: All sides must be positive, triangle inequality violation
110// Handled Edge Cases: All sides must be positive, triangle inequality violation
111// Handled Edge Cases: All sides must be positive, 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.