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 111 views
2 answers 172 views
2 answers 193 views
1 answer 155 views
1 answer 140 views
...