DEV Community

Discussion on: Rounding decimal numbers in Javascript - an interesting problem.

Collapse
cytim profile image
Tim Wong • Edited on

If you use Lodash, the problem is resolved right away.

_.round(4.975, 2)
// 4.98
Enter fullscreen mode Exit fullscreen mode

The Lodash implementation is also very clean.
github.com/lodash/lodash/blob/mast...