-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution0078.js
34 lines (22 loc) · 869 Bytes
/
solution0078.js
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
/*
--------------- 7 Kyu - Is this a triangle? ------------------
Instructions:
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).
-------------
Sample Tests
const { assert } = require("chai")
describe("Public tests", () => {
it("Testing for fixed tests", () => {
assert.strictEqual(isTriangle(1,2,2), true);
assert.strictEqual(isTriangle(7,2,2), false);
});
})
--------------
Psuedo Code:
-You can prove for a triagle by checking if the sum of all combinations of two sides is greater than the other side.
-Use ternary: return a+b > c && etc. ?
*/
function isTriangle(a,b,c) {
return a+b > c && a+c > b && b+c > a ? true : false
}