Skip to content

Commit c83ad2f

Browse files
committed
Done the implement and rewrite
1 parent 3372770 commit c83ad2f

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

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

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Implement a function getAngleType
2-
//
32
// When given an angle in degrees, it should return a string indicating the type of angle:
43
// - "Acute angle" for angles greater than 0° and less than 90°
54
// - "Right angle" for exactly 90°
@@ -15,12 +14,34 @@
1514
// execute the code to ensure all tests pass.
1615

1716
function getAngleType(angle) {
18-
// TODO: Implement this function
17+
function getAngleType(angle) {
18+
if (angle <= 0 || angle >= 360)
19+
}
20+
21+
if (angle < 90) {
22+
return "acute angle";
23+
}
24+
if (angle === 90) {
25+
return "right angle";
26+
}
27+
if (angle < 180){
28+
return "obtuse angle";
29+
}
30+
if (angle === 180){
31+
return "straight angle";
32+
}
33+
if (angle < 360){
34+
return "reflex angle";
1935
}
36+
module.exports = getAngleType;
37+
38+
39+
// TODO: Implement this function
40+
2041

2142
// The line below allows us to load the getAngleType function into tests in other files.
2243
// This will be useful in the "rewrite tests with jest" step.
23-
module.exports = getAngleType;
44+
2445

2546
// This helper function is written to make our assertions easier to read.
2647
// If the actual output matches the target output, the test will pass
@@ -35,3 +56,11 @@ function assertEquals(actualOutput, targetOutput) {
3556
// Example: Identify Right Angles
3657
const right = getAngleType(90);
3758
assertEquals(right, "Right angle");
59+
60+
// Test
61+
assertEquals(getAngleType(45), "Acute angle");
62+
assertEquals(getAngleType(90), "Right angle");
63+
assertEquals(getAngleType(120), "Obtuse angle");
64+
assertEquals(getAngleType(180), "Straight angle");
65+
assertEquals(getAngleType(270), "Reflex angle");
66+
assertEquals(getAngleType(390), "Invalid angle");

0 commit comments

Comments
 (0)