joseph

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 this.sides = [];
14 return;
15 }
16
17 // Edge Case: Check if all sides are numbers
18 if (sides.some(side => typeof side !== 'number')) {
19 this.sides = [];
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 // Edge Case: Check if triangle is valid
31 if (!this._isValidTriangle()) {
32 return false;
33 }
34
35 const [a, b, c] = this.sides;
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 // Edge Case: Check if triangle is valid
44 if (!this._isValidTriangle()) {
45 return false;
46 }
47
48 const [a, b, c] = this.sides;
49 return a === b || b === c || a === c;
2650 }
2751
2852 /**
2953 * @returns {boolean}
3054 */
3155 get isScalene() {
32 throw new Error('Remove this line and implement the function');
56 // Edge Case: Check if triangle is valid
57 if (!this._isValidTriangle()) {
58 return false;
59 }
60
61 const [a, b, c] = this.sides;
62 return a !== b && b !== c && a !== c;
63 }
64
65 /**
66 * Helper method to validate if the sides form a valid triangle
67 * @returns {boolean}
68 */
69 _isValidTriangle() {
70 // Edge Case: Check if sides array has exactly 3 elements
71 if (!this.sides || this.sides.length !== 3) {
72 return false;
73 }
74
75 const [a, b, c] = this.sides;
76
77 // Edge Case: Check if all sides are positive numbers
78 if (a <= 0 || b <= 0 || c <= 0) {
79 return false;
80 }
81
82 // Edge Case: Check triangle inequality theorem
83 if (a + b < c || b + c < a || a + c < b) {
84 return false;
85 }
86
87 return true;
3388 }
3489}
90
91// Handled Edge Cases:
92// - Invalid number of sides in constructor
93// - Non-numeric sides
94// - Invalid triangle (sides <= 0)
95// - Triangle inequality violation
96// - Equilateral check on invalid triangle
97// - Isosceles check on invalid triangle
98// - Scalene check on invalid triangle
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.