awesome

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 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: Check if it's a valid triangle first
31 if (!this._isValidTriangle()) {
32 return false;
33 }
34
35 // Edge Case: All sides must be equal for equilateral
36 return a === b && b === c;
1937 }
2038
2139 /**
2240 * @returns {boolean}
2341 */
2442 get isIsosceles() {
25 throw new Error('Remove this line and implement the function');
43 const [a, b, c] = this.sides;
44
45 // Edge Case: Check if it's a valid triangle first
46 if (!this._isValidTriangle()) {
47 return false;
48 }
49
50 // Edge Case: At least two sides must be equal for isosceles
51 return a === b || b === c || a === c;
2652 }
2753
2854 /**
2955 * @returns {boolean}
3056 */
3157 get isScalene() {
32 throw new Error('Remove this line and implement the function');
58 const [a, b, c] = this.sides;
59
60 // Edge Case: Check if it's a valid triangle first
61 if (!this._isValidTriangle()) {
62 return false;
63 }
64
65 // Edge Case: All sides must be different for scalene
66 return a !== b && b !== c && a !== c;
67 }
68
69 /**
70 * Helper method to check if the sides form a valid triangle
71 * @returns {boolean}
72 */
73 _isValidTriangle() {
74 const [a, b, c] = this.sides;
75
76 // Edge Case: All sides must have positive length
77 if (a <= 0 || b <= 0 || c <= 0) {
78 return false;
79 }
80
81 // Edge Case: Satisfy triangle inequality theorem
82 if ((a + b < c) || (b + c < a) || (a + c < b)) {
83 return false;
84 }
85
86 return true;
3387 }
3488}
89
90// Handled Edge Cases:
91// - Ensure exactly three sides are provided
92// - Ensure all sides are numbers
93// - Check if it's a valid triangle first in each type check
94// - All sides must be equal for equilateral
95// - At least two sides must be equal for isosceles
96// - All sides must be different for scalene
97// - All sides must have positive length
98// - Satisfy triangle inequality theorem
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.