← Back to challenges

Finding the Missing Sides of a Right Triangle

JavaScriptHardmathgeometry

Instructions

Consider a right triangle. Its area and hypotenuse are known.

Create a function that returns the two missing sides. The first input is the area and the second input is the hypotenuse. Return your answer as an array (the shorter side first). If there is no such right triangle, return "Does not exist".

Examples

f(3, 6) ➞ [1.015, 5.914]

f(30, 12) ➞ [5.675, 10.574]

f(30, 10) ➞ "Does not exist"

Notes

Round your answer to three decimal places.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.