This repository was archived by the owner on Apr 18, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathget-angle-type.test.js
More file actions
55 lines (41 loc) · 1.62 KB
/
get-angle-type.test.js
File metadata and controls
55 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Implement a function getAngleType, and tests for each of the acceptance criteria.
// Acceptance criteria:
// Identify Right Angles:
// When the angle is exactly 90 degrees,
// Then the function should return "Right angle"
// Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
// Identify Obtuse Angles:
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
// Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
// Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
function triangleAngle(degrees){
if (degrees === 90)
return 'Right angle';
else if (degrees < 90)
return 'Acute angle';
else if (degrees > 90 && degrees < 180)
return 'Obtuse';
else if (degrees === 180)
return 'Straight angle'
else if (degrees > 180 && degrees < 360)
return 'Reflex angle'
}
// console.log(triangleAngle(90));
// console.log(triangleAngle(45));
// console.log(triangleAngle(105));
// console.log(triangleAngle(180));
// console.log(triangleAngle(220));
test("idenity the angle type", function () {
expect(triangleAngle(90)).toBe("Right angle");
expect(triangleAngle(45)).toBe("Acute angle");
expect(triangleAngle(105)).toBe("Obtuse");
expect(triangleAngle(180)).toBe("Straight angle");
expect(triangleAngle(220)).toBe("Reflex angle");
});