In JavaScript, is there any way to convert a decimal number (such as 0.0002) to a fraction represented as a string (such as “2/10000")?
If a function called decimalToFraction had been written for this purpose, then decimalToFraction(0.0002) would return the string "2/10000".
You can use Erik Garrison’s fraction.js library to do that and more fractional operations.
To to do .003 you can just do