Skip to content

Instantly share code, notes, and snippets.

@slonka
Created January 5, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slonka/dbc4e83f6c2ebf4dd1efe459cad516e3 to your computer and use it in GitHub Desktop.
Save slonka/dbc4e83f6c2ebf4dd1efe459cad516e3 to your computer and use it in GitHub Desktop.
// a + b > c , a + c > b, b + c > a
function triangleInequality(a, b, c) {
if (typeof a !== 'number' || typeof b !== 'number' || typeof c !== 'number') {
return NaN
}
return (a + b) > c && (a + c) > b && (b + c) > a;
}
console.log('1', triangleInequality(3, 4, 5));
console.log('2', triangleInequality(1, 2, 4));
console.log('3', triangleInequality('string', 2, 4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment