JavaScript StrToFloat


/ Published in: JavaScript
Save to your folder(s)

Convert str to float;


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.