Posted By

kzelda on 01/20/13


Tagged

strstrtofloatfloatcast


Versions (?)

JavaScript StrToFloat


 / Published in: JavaScript
 

Convert str to float;

  1. function strToFloat(s) {
  2. try {
  3. return parseFloat(s.replace(",00", "").replace(/\s+/g, "").replace(" ", "").replace(",", "."));
  4. }
  5. catch (e) {
  6. return 0;
  7. }
  8. }

Report this snippet  

You need to login to post a comment.