Skip to content

Commit 572f7eb

Browse files
committed
Added check traingle type program
1 parent 08c0cf3 commit 572f7eb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

checkTriangle.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* -------------------------------------------------------
3+
* Programming Question : CheckTriangleType
4+
* -------------------------------------------------------
5+
**/
6+
7+
8+
// Q. Write a function called checkTriangleType that takes three parameters representing the lengths of the slides of a triangle. The function should return a string indicating the type of triangle: "equilateral", "isosceles", or "scalene"
9+
10+
//constraint
11+
//? If all three sides are of equal length, return "equilateral";
12+
//? If all two sides are of equal length, return "isosceles";
13+
//? If all three sides are of different length, return "scalene";
14+
15+
16+
/** steps
17+
*
18+
19+
**/
20+
21+
function checkTriangleType(a,b,c) {
22+
let result ="";
23+
if(a==b && b==c){
24+
result = "Equilateral";
25+
}else if(a===b || b==c){
26+
result = "scelene";
27+
}else{
28+
result = "isosceles";
29+
}
30+
return result
31+
}
32+
33+
console.log(checkTriangleType(3,4,5));
34+
console.log(checkTriangleType(4,4,5));
35+
console.log(checkTriangleType(5,5,5));
36+
console.log(checkTriangleType(3,4,4));
37+
console.log(checkTriangleType(0,1,2));

0 commit comments

Comments
 (0)