How to round a number to 3 decimal places in JavaScript

2 Answers

0 votes
let num = 9.351298;

num = Number(num.toFixed(3));

console.log(num); 

   
   
   
   
/*
run:
   
9.351
   
*/

 



answered Jun 18, 2022 by avibootz
0 votes
let num = 9.452897;

num = Number(num.toFixed(3));

console.log(num); 

   
   
   
   
/*
run:
   
9.453
   
*/

 



answered Jun 18, 2022 by avibootz

Related questions

2 answers 137 views
2 answers 157 views
3 answers 314 views
4 answers 256 views
4 answers 234 views
2 answers 190 views
...