I've built an algorithm to convert meters into ... other things.
See log.
Here's an input:
Here's the output:
Click me to show info in the console
Story
Convert any distance in meters into a relevant unit – from nanometers to astronomical units.
Avoid over-precision ie don't include meters in 100s of km
Example output
1 m is 1 m
0.009 m is 9 mm
.01 m is 1 cm
999 m is just under 10 km
Tests