Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Javascript round number after the . to 3 digits only

I have a variable with a result that looks like this:

myresult = 14.4565576

I need to round the decimal after the DOT to only 3 numbers.

For example I need to round this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

14.4565576

to this:

14.456

How can I do this?

>Solution :

You can use the toFixed method

const number = 14.4565576
console.log(number.toFixed(3))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading