title: convert decimal number to fraction in javascript or closest fraction
body: <p>So i want to be able to convert any decimal number into fraction. In both forms such as one without remainder like this: <code>3/5</code> or with remainder: <code>3 1/4</code>.</p>
  
  <p>what i was doing is this..</p>
  
  <p>lets say i have number .3435.</p>
  
  <ul>
  <li>Calculate amount of digits after decimals.</li>
  <li>multiply by 10 with power of the amount before number.</li>
  <li>then <strong>somehow</strong> find greatest common factor.</li>
  </ul>
  
  <p>Now i don't know how to find GCF. And nor i know how to implement logic to find fraction that represents a number closely or in remainder form if exact fraction doesn't exists.</p>
  
  <p>code i have so far: (testing)</p>
  
  <pre><code>x = 34/35;
  a = x - x.toFixed();
  tens = (10).pow(a.toString().length - 2);
  
  numerator = tens * x;
  denominator = tens;
  </code></pre>