# All files / algorithms/lib isTriangle.ts

0% Statements 0/12
0% Branches 0/1
0% Functions 0/1
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

     export function isTriangle(a: number, b: number, c: number): boolean {
      if (a < 0 || b < 0 || c < 0) return false;

      return a + b > c && a < b + c && b < a + c;
    }

    console.log(isTriangle(7, 2, 2), false);
    console.log(isTriangle(1, 2, 2), true);
    console.log(isTriangle(4, 2, 3), true);
    console.log(isTriangle(2, 2, 2), true);
    console.log(isTriangle(1, 2, 3), false);
    console.log(isTriangle(-5, 1, 3), false);
    console.log(isTriangle(0, 2, 3), false);
    console.log(isTriangle(1, 2, 9), false);