-3

I'd like to round up to 2 decimal places.

Input: 2.456 2.890

Output: 2.500 2.900

How can I do this in JavaScript?

  • 3
    i think this can help you, why you dont google it first? http://stackoverflow.com/questions/6134039/format-number-to-always-show-2-decimal-places – Pavul Zavala Aug 17 '16 at 02:57
  • 4
    Possible duplicate of [How to round float numbers in javascript?](http://stackoverflow.com/questions/9453421/how-to-round-float-numbers-in-javascript) – Jason Cust Aug 17 '16 at 02:59

1 Answers1

1

Use Math.round(num * 100) / 100

Tony Vincent
  • 13,354
  • 7
  • 49
  • 68