← Back to challenges

Planetary Weight Converter

JavaScriptHardmathobjectsphysics

Instructions

In this challenge, you have to convert a weight weighed on a planet of the Solar System to the corresponding weight on another planet.

To convert the weight, you have to divide it by the gravitational force of the planet on which is weighed and multiply the result (the mass) for the gravitational force of the other planet. See the table below for a list of gravitational forces:

weight on planetA / gravitational force of planetA * gravitational force of planetB

Planetm/s²
Mercury3.7
Venus8.87
Earth9.81
Mars3.711
Jupiter24.79
Saturn10.44
Uranus8.69
Neptune11.15

Given a weight weighed on planetA, return the converted value for planetB rounded to the nearest hundredth.

Examples

spaceWeights("Earth", 1, "Mars") ➞ 0.38

spaceWeights("Earth", 1, "Jupiter") ➞ 2.53

spaceWeights("Earth", 1, "Neptune") ➞ 1.14

Notes

N/A

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