kale

Finished
88 * @param {...number} sides
99 */
1010 constructor(...sides) {
11 throw new Error('Remove this line and implement the function');
11 // Edge Case: Handle when not exactly 3 sides are provided
12 if (sides.length !== 3) {
13 this.sides = [0, 0, 0];
14 return;
15 }
16
17 // Edge Case: Handle non-numeric values
18 if (sides.some(side => typeof side !== 'number' || isNaN(side))) {
19 this.sides = [0, 0, 0];
20 return;
21 }
22
23 // Edge Case: Handle infinite or negative values
24 if (sides.some(side => !isFinite(side) || side <= 0)) {
25 this.sides = [0, 0, 0];
26 return;
27 }
28
29 this.sides = sides;
1230 }
1331
1432 /**
1533 * @returns {boolean}
1634 */
1735 get isEquilateral() {
18 throw new Error('Remove this line and implement the function');
36 const [a, b, c] = this.sides;
37
38 // Edge Case: Handle invalid triangle
39 if (a <= 0 || b <= 0 || c <= 0) {
40 return false;
41 }
42
43 // Edge Case: Handle triangle inequality violation
44 if (a + b < c || b + c < a || a + c < b) {
45 return false;
46 }
47
48 return a === b && b === c;
1949 }
2050
2151 /**
2252 * @returns {boolean}
2353 */
2454 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
55 const [a, b, c] = this.sides;
56
57 // Edge Case: Handle invalid triangle
58 if (a <= 0 || b <= 0 || c <= 0) {
59 return false;
60 }
61
62 // Edge Case: Handle triangle inequality violation
63 if (a + b < c || b + c < a || a + c < b) {
64 return false;
65 }
66
67 return a === b || b === c || a === c;
2668 }
2769
2870 /**
2971 * @returns {boolean}
3072 */
3173 get isScalene() {
32 throw new Error('Remove this line and implement the function');
74 const [a, b, c] = this.sides;
75
76 // Edge Case: Handle invalid triangle
77 if (a <= 0 || b <= 0 || c <= 0) {
78 return false;
79 }
80
81 // Edge Case: Handle triangle inequality violation
82 if (a + b < c || b + c < a || a + c < b) {
83 return false;
84 }
85
86 return a !== b && b !== c && a !== c;
3387 }
3488}
89
90// Handled Edge Cases: zero or negative side lengths, non-numeric values, infinite values, wrong number of sides, triangle inequality violations
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.