Possible Duplicate:
How can I format numbers as money in JavaScript?
Format number to always show 2 decimal places
How do I round to 2 decimal places?
In PHP I can do the following to round to 2 decimal places;
$number = 3.45667;
$result = number_format($number, 2, '.', ''); // 3.46
How can I do the same in JavaScript?
This will however not quite work like PHP’s
number_format(). I.e. it will not convert 2.4 to 2.40. In order for that to work, you’ll need a little more: