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 166 views
1 answer 193 views
1 answer 183 views
1 answer 245 views
1 answer 238 views
3 answers 487 views
...