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

1 Answer

0 votes
const num:number = 783.9348745;

console.log(num.toFixed());

console.log(num.toFixed(1));

console.log(num.toFixed(2));

console.log(num.toFixed(3));
 
 
 
     
     
/*
run:

"784" 
"783.9" 
"783.93" 
"783.935" 
     
*/

  

 



answered Aug 11, 2022 by avibootz

Related questions

1 answer 95 views
1 answer 132 views
1 answer 137 views
1 answer 100 views
1 answer 129 views
...