How to parse float with 2 decimal places in Node.js

2 Answers

0 votes
let f = 6.1936;
 
f = parseFloat(f).toFixed(2);
 
console.log(f); 
 
 
   
   
   
/*
run:
   
6.19
   
*/

 



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

 



answered Jun 19, 2022 by avibootz

Related questions

...