Home > Net >  Javascript round number after the . to 3 digits only
Javascript round number after the . to 3 digits only

Time:06-10

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:

14.4565576

to this:

14.456

How can I do this?

CodePudding user response:

You can use the toFixed method

const number = 14.4565576
console.log(number.toFixed(3))

  • Related