Skip to content

Commit 0359cea

Browse files
Install npm and jest test ino the section of the course work begin the first course work test
1 parent 3372770 commit 0359cea

File tree

4 files changed

+4514
-0
lines changed

4 files changed

+4514
-0
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616

1717
function getAngleType(angle) {
1818
// TODO: Implement this function
19+
switch (true) {
20+
case (0 < angle && angle < 90):
21+
return "Acute angle";
22+
case (angle === 90):
23+
return "Right angle";
24+
case (90 < angle && angle < 180):
25+
return "Obtuse angle";
26+
case (angle === 180):
27+
return "Straight angle";
28+
case (180 < angle && angle < 360):
29+
return "Reflex angle";
30+
case ( angle <= 0 || angle >= 360) :
31+
return "Invalid angle";
32+
}
1933
}
2034

2135
// The line below allows us to load the getAngleType function into tests in other files.
@@ -33,5 +47,30 @@ function assertEquals(actualOutput, targetOutput) {
3347

3448
// TODO: Write tests to cover all cases, including boundary and invalid cases.
3549
// Example: Identify Right Angles
50+
// Acute angle
51+
const acute = getAngleType(45);
52+
assertEquals(acute, "Acute angle");
53+
54+
// Right angle
3655
const right = getAngleType(90);
3756
assertEquals(right, "Right angle");
57+
58+
// Obtuse angle
59+
const obtuse = getAngleType(120);
60+
assertEquals(obtuse, "Obtuse angle");
61+
62+
// Straight angle
63+
const straight = getAngleType(180);
64+
assertEquals(straight, "Straight angle");
65+
66+
// Reflex angle
67+
const reflex = getAngleType(270);
68+
assertEquals(reflex, "Reflex angle");
69+
70+
// Invalid angle (below range)
71+
const invalidLow = getAngleType(0);
72+
assertEquals(invalidLow, "Invalid angle");
73+
74+
// Invalid angle (above range)
75+
const invalidHigh = getAngleType(360);
76+
assertEquals(invalidHigh, "Invalid angle");

0 commit comments

Comments
 (0)