Implement a function that accepts 3 integer values a, b, c. The function should return true if a triangle can be built with the sides of given length and false in any other case.
(In this case, all triangles must have surface greater than 0 to be accepted).
function isTriangle(a,b,c)
{
if (a <= 0 || b <= 0 || c <= 0)
return false;
let arr = [a, b, c].sort((a, b) => a - b);
return arr[2] < arr[0] + arr[1];
}
새로운 배열을 만드는 게 아니라 이렇게 구조분해로도 가능하다!
function isTriangle(a,b,c)
{
[a, b, c] = [a, b, c].sort((x, y) => x-y);
return a+b > c;
}