There is such a function:
function isTriangle(a,b,c) { for(var i = 0; i < arguments.length; i++) { if (arguments[i] == 0) { return false } for(var k = 0; k < arguments.length; k++) { var sum = 0; for(var m = 0; m < arguments.length; m++) { sum += arguments[m]; } sum = sum - arguments[i]; if (arguments[i] > sum) { return false } } } return true; } It takes three parameters, returns true if it is possible to build a triangle with such sides, and returns false if not.
I checked the function, it works well, but some condition of the task is apparently not met and the task does not skip.
Conditions:
Implement a method that accepts 3 integer values a, b, c. It can be used to make it so that it can be built up.
(In this case, all triangles must have greater than 0 to be accepted)
.
What am I doing wrong? Task with codewars.
sum = a + b + c, then one of the arguments is subtracted from the sum and a comparison is made. That is,sum = b + ccompared witha. What prevents to immediately compare a> b + c? And so all sides. Even checking for zero is not necessary. - Adokenai