jackson

Finished
88 * @param {...number} sides
99 */
1010 constructor(...sides) {
11 throw new Error('Remove this line and implement the function');
11 // Edge Case: Ensure exactly three sides are provided
12 if (sides.length !== 3) {
13 throw new Error('Triangle must have exactly three sides');
14 }
15
16 // Edge Case: Ensure all sides are numbers
17 if (sides.some(side => typeof side !== 'number')) {
18 throw new Error('All sides must be numbers');
19 }
20
21 // Edge Case: Ensure all sides are positive
22 if (sides.some(side => side <= 0)) {
23 this.isValid = false;
24 return;
25 }
26
27 const [a, b, c] = sides;
28
29 // Edge Case: Check triangle inequality theorem
30 if (a + b < c || b + c < a || a + c < b) {
31 this.isValid = false;
32 return;
33 }
34
35 this.sides = sides;
36 this.isValid = true;
1237 }
1338
1439 /**
1540 * @returns {boolean}
1641 */
1742 get isEquilateral() {
18 throw new Error('Remove this line and implement the function');
43 // Edge Case: Invalid triangle
44 if (!this.isValid) {
45 return false;
46 }
47
48 const [a, b, c] = this.sides;
49 return a === b && b === c;
1950 }
2051
2152 /**
2253 * @returns {boolean}
2354 */
2455 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
56 // Edge Case: Invalid triangle
57 if (!this.isValid) {
58 return false;
59 }
60
61 const [a, b, c] = this.sides;
62 return a === b || b === c || a === c;
2663 }
2764
2865 /**
2966 * @returns {boolean}
3067 */
3168 get isScalene() {
32 throw new Error('Remove this line and implement the function');
69 // Edge Case: Invalid triangle
70 if (!this.isValid) {
71 return false;
72 }
73
74 const [a, b, c] = this.sides;
75 return a !== b && b !== c && a !== c;
3376 }
3477}
78
79// Handled Edge Cases:
80// 1. Ensure exactly three sides are provided
81// 2. Ensure all sides are numbers
82// 3. Ensure all sides are positive
83// 4. Check triangle inequality theorem
84// 5. Invalid triangle for all type checks
85// 6. Equilateral triangle check
86// 7. Isosceles triangle check
87// 8. Scalene triangle check
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.