SV: [thelist] JavaScript: trim function?

Marcus Andersson marcan at home.se
Fri Nov 14 11:19:20 CST 2003


  

> 
> Which gives me 4234...i need the two decimal places...
>

How about: 
 
  function trimNumber(number, digits) {
    return Math.round(number * Math.pow(10, digits)) / ((Math.pow(10,
digits) * 1.0));        
  }

/Marcus



More information about the thelist mailing list