Skip to content

Commit dfdbad9

Browse files
authored
Implement getAngleType function and add tests
Implement the getAngleType function to classify angles and add tests for various cases.
1 parent 3372770 commit dfdbad9

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,34 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
// TODO: Implement this function
18+
function getAngleType(angle) {
19+
if (angle <= 0 || angle >= 360)
20+
}
21+
22+
if (angle < 90) {
23+
return "actue angle";
24+
}
25+
if (angle === 90) {
26+
return "right angle";
27+
}
28+
if (angle < 180){
29+
return "obtuse angle";
30+
}
31+
if (angle === 180){
32+
return "straight angle";
33+
}
34+
if (angle < 360){
35+
return "reflext angle";
1936
}
37+
module.exports = getAngleType;
38+
39+
40+
// TODO: Implement this function
41+
2042

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

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

0 commit comments

Comments
 (0)