How to convert a string to float in JavaScript

1 Answer

0 votes
const s = "3.0070"

const f = parseFloat(s)

console.log(f);
console.log(typeof f); 

  
    
    
    
/*
run:
    
3.007
"number"
    
*/

  

 



answered Aug 12, 2021 by avibootz

Related questions

...