The Pythagorean Theorem
by Nonamenonamevi4
JavaScript
function pythagoreanTheorem(hypotenuse, firstCatheter, secondCatheter) {
if (hypotenuse == "Неизвестно") {
hypotenuse = (firstCatheter * firstCatheter) + (secondCatheter * secondCatheter);
hypotenuse = Math.sqrt(hypotenuse);
return hypotenuse;
} else if (firstCatheter == "Неизвестно") {
firstCatheter = (hypotenuse * hypotenuse) - (firstCatheter * firstCatheter)
firstCatheter = Math.sqrt(firstCatheter);
return firstCatheter;
} else if (secondCatheter == "Неизвестно") {
secondCatheter = (hypotenuse * hypotenuse) - (secondCatheter * secondCatheter)
secondCatheter = Math.sqrt(secondCatheter);
return secondCatheter;
} else {
return "Какая-то ошибка"
}
}