Last Updated: February 25, 2016
·
936
· landongn

Use 138.toFixed(int) to round numbers

Rather than using Math.Round, use toFixed() to get an arbitrary decimal limit to your rounded number.

note: this isn't extremely precise, per se, but it works well for things that just need to be "close".

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside