How to print fixed-point notation of a number in JavaScript

1 Answer

0 votes
const num = 981.946073;
 
console.log(num.toFixed());
 
console.log(num.toFixed(1));
 
console.log(num.toFixed(2));
 
console.log(num.toFixed(3));
  
  
  
      
      
/*
run:

"982"
"981.9"
"981.95"
"981.946"
      
*/

 



answered Aug 12, 2022 by avibootz

Related questions

1 answer 168 views
1 answer 194 views
1 answer 184 views
1 answer 246 views
1 answer 239 views
3 answers 488 views
...