How to parse float with 2 decimal places in TypeScript

2 Answers

0 votes
let f = 9.1936;
 
f = parseFloat(f).toFixed(2);
 
console.log(f); 
 
 
   
   
   
/*
run:
   
"9.19" 
   
*/

 



answered Jun 19, 2022 by avibootz
0 votes
let f = 9.1987;
 
f = parseFloat(f).toFixed(2);
 
console.log(f); 
 
 
   
   
   
/*
run:
   
"9.20" 
   
*/

 



answered Jun 19, 2022 by avibootz

Related questions

2 answers 108 views
2 answers 127 views
2 answers 127 views
...