Algorithm/codewars

Is this a triangle? 답안

Bonita SY 2021. 3. 23. 20:00
728x90

문제)

www.codewars.com/kata/56606694ec01347ce800001b/train/javascript

 

Codewars: Achieve mastery through challenge

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

 

내가 푼 답)

function isTriangle(a,b,c)
{
  var triList = [a, b, c].sort().reverse();
  if (triList[0] < (triList[1] + triList[2])) {
    return true;
  } else {
    return false;
  }
}

 

테스트 결과)

 

참고할 만한 다른 사람 소스)

728x90