Js Numbers - fractions


I want it:

There is var number = 0.33 on the website, and I want var second = fractions of variable 'number' , and if the fractions "number" are changed: second will change.

But how?

+5
source share
1 answer

You can use the Erik Garrison fraction.js library to do this and more fractional operations.

 var second = new Fraction(.033); console.log(second.numerator + '/' + second.denominator); 
+5
source

All Articles