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 this.sides = sides;
1224 }
1325
1426 /**
1527 * @returns {boolean}
1628 */
1729 get isEquilateral() {
18 throw new Error('Remove this line and implement the function');
30 const [a, b, c] = this.sides;
31
32 // Edge Case: Check if all sides are positive
33 if (a <= 0 || b <= 0 || c <= 0) {
34 return false;
35 }
36
37 // Edge Case: Check triangle inequality
38 if (!(a + b >= c && b + c >= a && a + c >= b)) {
39 return false;
40 }
41
42 return a === b && b === c;
1943 }
2044
2145 /**
2246 * @returns {boolean}
2347 */
2448 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
49 const [a, b, c] = this.sides;
50
51 // Edge Case: Check if all sides are positive
52 if (a <= 0 || b <= 0 || c <= 0) {
53 return false;
54 }
55
56 // Edge Case: Check triangle inequality
57 if (!(a + b >= c && b + c >= a && a + c >= b)) {
58 return false;
59 }
60
61 return a === b || b === c || a === c;
2662 }
2763
2864 /**
2965 * @returns {boolean}
3066 */
3167 get isScalene() {
32 throw new Error('Remove this line and implement the function');
68 const [a, b, c] = this.sides;
69
70 // Edge Case: Check if all sides are positive
71 if (a <= 0 || b <= 0 || c <= 0) {
72 return false;
73 }
74
75 // Edge Case: Check triangle inequality
76 if (!(a + b >= c && b + c >= a && a + c >= b)) {
77 return false;
78 }
79
80 return a !== b && b !== c && a !== c;
3381 }
3482}
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.