How to remove trailing zeros from a float number in TypeScript

2 Answers

0 votes
let num = 33.1415000;
 
num = parseFloat(num);
 
console.log(num); 
 
 
 
   
   
   
/*
run:
   
33.1415 
   
*/

 



answered Jun 19, 2022 by avibootz
0 votes
let num = 33.1415000;
 
num = parseFloat(num.toFixed(4));
 
console.log(num); 
 
 
 
   
   
   
/*
run:
   
33.1415 
   
*/

 



answered Jun 19, 2022 by avibootz

Related questions

1 answer 117 views
2 answers 182 views
2 answers 209 views
1 answer 161 views
1 answer 150 views
...