title: JavaScript: Trim .toPrecision() trailing zeros
body: <p>I am creating an online calculator using JavaScript.</p>
  
  <p>I have this to work out a calculation:</p>
  
  <pre><code>eval(expression).toPrecision(10);
  </code></pre>
  
  <p>This produces the right output in almost all cases. E.g.</p>
  
  <pre><code>eval('456456+45646486*45646884').toPrecision(10)
  // Output: "2.083619852e+15"
  
  eval('1/0').toPrecision(10)
  // Output: "Infinity"
  </code></pre>
  
  <p>However</p>
  
  <pre><code>eval('4*1').toPrecision(10)
  // Output: "4.000000000"
  </code></pre>
  
  <p>How do I trim the trailing zeros <strong>but</strong> also keep nice outputs above?</p>