programming-examples/js/Math/Pythagorean function in JavaScript.js

8 lines
293 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function pythagorean_theorem(x, y) {
if ((typeof x !== 'number') || (typeof y !== 'number'))
return false;
return Math.sqrt(x * x + y * y);
}
console.log(pythagorean_theorem(2, 4));
console.log(pythagorean_theorem(3, 4));